Sunday, 17 June 2012

Write a shell script to accept an alphabet from the user and list all the files/directory starting with that alphabet in the current directory


echo enter character
read c
for i in `ls -l|tr -s " "|cut -d " " -f 9`
do
 x=`echo $i|cut -c 1`
if [ $x = $c ]
then echo $i
fi
done

No comments:

Post a Comment