First page Back Continue Last page Overview Graphics
Example 4-2
example4_2_number_dir.bash
# This scripts finds number of files for each directory D* and reports it on the screen.
# The command echo echoes what ever is written in front of it
echo "Directory Number of files”
ls -d D* | while
read dir_name
do
# notice that the results of all commands within ` some commands` will go to the designated variable num
num=`ls $dir_name/* |wc -l `
# The command echo will echo the content variables
echo $dir_name " " $num
done
echo "program is finished"