First page Back Continue Last page Overview Graphics
Example 4-3
Automation using sort and uniq: Example
# The scripts finds number of files for each directory D* and reports it on the screen.
echo "Dirrectory #files #stations #expected files"
ls -d D* | while
read dir_name
do
num=`ls $dir_name/* |wc -l `
num_uniq=`ls $dir_name/* |awk '{if(substr($0,22,1) == "_") print substr($0,18,4);else print substr($0,19,3)}' |sort |uniq |wc -l`
echo $dir_name " " $num " " $num_uniq
done
echo "program is finished"