Hi all
I want to count total numbers of sentences separated by fullstop (.) in different files under a directory at one go. Any help is appreciated.
Hi all
I want to count total numbers of sentences separated by fullstop (.) in different files under a directory at one go. Any help is appreciated.
find -type f -exec grep -o '\.' {} \; | wc -l
The above may satisfy your requirement with some limitations in it.
find . -type f -exec cat {} \; | tr '.' "\n" | grep -v "^$" | wc -l
The abobe command will give you total number of sentences in all the files in that directory.
for file in `find . -type f`
do
echo -n $file
cat $file | tr '.' "\n" | grep -v "^$" | wc -l
done
Above script will give the numbers of sentences in each file.
Try
$ for f in `find . -type f `
do
awk 'BEGIN { RS="." } END { print FILENAME, NR - 1 }' $f
done