Bash Programming Practice
Contents
1.Count the lines in .c files in a working directory and all its subdirectories
#!/bin/bash
workspace=.
if [ "$#" -eq 1 ]
then
$workspace=$1
fi
wc -l `find $workspace -name '*.c'` | tail -n -1 | cut -d " " -f 2
exit 0
2.Count the occurrences of the ten most frequent words in a file
#!/bin/bash
filename=$1
cat $filename | sort | uniq -c | sort -k1,1nr | head -10
8:30 -8:00, xz 9:00 10:30 [game p] , hh 7:30 9:00 [sport]
6 --> paper book
lt yxl
sz
mtlife chicken