Shell script

You have current directory containing set of directories which contain files.
One file can reside in many directories.
Write script which returns number of unique file names in
all the subdirectories of a current dir.

Questions by Namataraginu

Showing Answers 1 - 3 of 3 Answers

sesethi

  • Feb 15th, 2009
 

Shell script accepts parameters in following format…
$1 would be the first command line argument, $2 the second, and so on
$0 is the name of the script or function
If your script has more than 9 params then accept in following way…
${12} : 12th param
${18} : 18th param

  Was this answer useful?  Yes

sesethi

  • Feb 15th, 2009
 

echo $string | cut -d” ” -f1 
echo $string | cut -d” ” -f2 
echo $string | cut -d” ” -f3

  Was this answer useful?  Yes

sesethi

  • Feb 15th, 2009
 

set -x
input_string=$1
if [ -z "$input_string" ] ; then
echo "Please enter a Text along with the script namen"
exit
fi


reversed_string=$(rev $input-string)
if [ "$input_string" -eq "$reverse_string" ] ; then
echo "The String $input_String is a Palindrome"
else
echo "This string is not a palindrome"
fi

  Was this answer useful?  Yes

ajay goel

  • Jun 28th, 2014
 

Find . -type f | sort| uniq

  Was this answer useful?  Yes

Tigran Petrosyan

  • Oct 23rd, 2014
 

Code
  1. find ./ -type f -printf %f

  2. |sort|uniq -c |awk {print $1}|grep ^1$|wc -l

  Was this answer useful?  Yes

abdul

  • Nov 7th, 2014
 

ls *|sort|grep -v ":$"|uniq -c

  Was this answer useful?  Yes

Igor Sarkisov

  • Feb 8th, 2015
 

Code
  1. find . -type f | xargs basename | sort | uniq | wc -l

  Was this answer useful?  Yes

Ataul

  • May 20th, 2015
 

ls * | grep -v ":$" | uniq -c | wc -l

  Was this answer useful?  Yes

Rajesh Anasuri

  • Sep 1st, 2015
 

find . -type f | awk -F / {print $(NF)} | sort | uniq

  Was this answer useful?  Yes

Nawaz

  • Jun 9th, 2017
 

find ./ -type f -exec basename {} ; | sort | uniq

  Was this answer useful?  Yes

Yogesh

  • Aug 31st, 2017
 

ls -lrt or any path | sort -nr |uniq-c

  Was this answer useful?  Yes

pranav Rakesh

  • Sep 26th, 2017
 

ls -lR|sort -u

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

Answer Question

Click here to Login / Register your free account


 
Send   Reset

 

Related Answered Questions

 

Related Open Questions