Operating System Shell Scripting/Programs on Linux
Linux Shell Scripting programs
Sunday, 17 June 2012
Write a shell script to find the number of ordinary files and directory files in the current directory
f=0
d=0
for i in `ls -l|tr -s " "|cut -c 1`
do
if [ $i = "-" ]
then
f=`expr $f + 1`
elif [ $i = "d" ]
then
d=`expr $d + 1`
fi
done
echo no of ordinary files are $f
echo no of directories are $d
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment