Thursday, 20 June 2013

Write a shell script to implement ‘ls’ command?



a = $#
if [ $# - = 0 ]
then
ls – r
fi
if [ $1 = “l” ]
then
ls – l
fi
if [ $1 =  “ –I “ ]
then
ls – i
fi
if [ $# - eq 2 ]
then
if [ $1 = “-l” –a $2 = “-r” – o $1 = “-r” –a $2 = “-l” ]
then
ls – ls
fi
if [ $1 = “-r” –a  $2 = “-i” – 0 $1 = “-i” –a  $2 = “-r” ]
then
ls – ri
fi
if [ $1 = “-l” – a $2 = “-i” – 0 $1 = “-i” –a $2 = “-l” ]
then
ls – li
fi
fi





OUTPUT:

Sh $h les .sh – i 310952 fname
310951 changes dir.sh 310734 gr 100 .sh 319749 dir
$sh les .sh – r
word .sh sq .sh mul table .sh
gr 100 .sh file while loop .sh

No comments:

Post a Comment