GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  Operating System  >  Shell Scripting
Go To First  |  Previous Question  |  Next Question 
 Shell Scripting  |  Question 39 of 47    Print  
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.



  
Total Answers and Comments: 4 Last Update: February 16, 2009     Asked by: Namataraginu 
  
 Sponsored Links

 
 Best Rated Answer
Submitted by: rps1007
 
"ls -R|sort|uniq"  should work

Above answer was rated as good by the following members:
dph1007, Ajay Kanse, amitkshirsagar
May 12, 2008 07:23:52   #1  
rps1007 Member Since: May 2008   Contribution: 2    

RE: Shell script
"ls -R|sort|uniq" should work
 
Is this answer useful? Yes | NoAnswer is useful 3   Answer is not useful 0Overall Rating: +3    
February 15, 2009 19:12:20   #2  
sesethi Member Since: October 2008   Contribution: 9    

RE: Shell script

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


 
Is this answer useful? Yes | No
February 15, 2009 19:17:55   #3  
sesethi Member Since: October 2008   Contribution: 9    

RE: Shell script

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


 
Is this answer useful? Yes | No
February 15, 2009 19:22:24   #4  
sesethi Member Since: October 2008   Contribution: 9    

RE: Shell script

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


 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape