Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Write a shell script that reads a folder name from the keyboard and computes the average
- # number of lines from each text file inside it and its subfolders.
- #!/bin/sh
- read D
- if [ ! -d $D ]
- then
- echo $D is not a directory.
- exit 1
- fi
- s=0
- n=0
- for fis in `find $D -type f`
- do
- l=`grep -c ".*" $fis`
- s=`expr $s + $l`
- n=`expr $n + 1`
- done
- avg=`expr $s / $n`
- echo $avg
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement