Write a shell script to find the number of files in a directory.
FILE="/tmp/count.txt"
echo -n "Enter directory name : "
read dname
ls $dname > $FILE
echo "No of files in directory : $(grep [^*$] $FILE -c)"
rm -f $FILE
FILE="/tmp/count.txt"
echo -n "Enter directory name : "
read dname
ls $dname > $FILE
echo "No of files in directory : $(grep [^*$] $FILE -c)"
rm -f $FILE
Leave a comment