counting number of sentence


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting counting number of sentence
# 1  
Old 09-18-2009
counting number of sentence

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.
# 2  
Old 09-18-2009
Code:
find -type f -exec grep -o '\.' {} \; | wc -l

The above may satisfy your requirement with some limitations in it.
# 3  
Old 09-18-2009
Code:
 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.

Code:
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.
# 4  
Old 09-18-2009
Try

Code:
$ for f in `find . -type f `
do 
    awk 'BEGIN { RS="." } END { print FILENAME, NR - 1 }' $f 
done

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help: Counting values less than a number

So I have several files (35000, to be exact) in the format rmsd_protein_*.dat each with 2 columns and 35000 rows. I would like to count how many values in the second column are less than 3 for each file, and output it into a new file so that it ultimately appears as: 1 14057 2 ... (12 Replies)
Discussion started by: Alexandryne
12 Replies

2. Shell Programming and Scripting

How to receive a specific alphanumeric number from a sentence?

Hi, I am quite new to shell scripting. I am facing challenge in retrieving a specific number from a sentence from the log. the number is random and changes everytime in the log. For example, The number of rows updated in table is: 7000 The number of rows updated in table is: 8000 The... (3 Replies)
Discussion started by: arghadeep adity
3 Replies

3. Shell Programming and Scripting

How to get a number from a grepped sentence of a file?

I want get a number(ID) from a sentence which has been grepped from file using error number. For Example: #!/bin/ksh echo "Enter RRS ID: " read rrs echo "Enter error number:" read err scp -pr ptc-avdbamdw102:/home/icsprd/M3logs/Accurate/logs/corp_post/$rrs.*.err.txt $HOME/daemon_mail/... (7 Replies)
Discussion started by: JayDoshi
7 Replies

4. Shell Programming and Scripting

Counting the number of characters

Hi all, Can someone help me in getting the following o/p I/p:... (7 Replies)
Discussion started by: Sri3001
7 Replies

5. UNIX for Dummies Questions & Answers

Script to ask for a sentence and then count number of spaces in the sentence

Hi People, I need some Help to write a unix script that asks for a sentence to be typed out then with the sentence. Counts the number of spaces within the sentence and then echo's out "The Number Of Spaces In The Sentence is 4" as a example Thanks Danielle (12 Replies)
Discussion started by: charlie101208
12 Replies

6. Shell Programming and Scripting

counting the number of occurences

say i've got a text file with >10million sequences: ssss ssss tttttt uuuuuu uuuuuu uuuuuu ... I'd like to convert the file so that the output will report the number of occurence right by each sequence: 2 ssss 2 ssss 1 tttttt 3 uuuuuu 3 uuuuuu 3 uuuuuu .... (3 Replies)
Discussion started by: johjoh
3 Replies

7. Shell Programming and Scripting

counting the number of lines - again

Hi all, I use bash shell and I have a problem with wc. I would like to determine the number of lines in a file so I do wc -l filename but I don't want to get the filename again I just would like to have the number of lines and use it in a variable. Can anybody help? Thank you, (7 Replies)
Discussion started by: f_o_555
7 Replies

8. Shell Programming and Scripting

Counting the number of pipes in line

Hi, I'm using the ksh shell. The scenario: I have a couple of directories /home/fd /home/fd/prsd home/fd/stg now i have number of files in each of these directories. some of the files are zipped using gzip so their extension is .gz the content of the files is as follows ... (4 Replies)
Discussion started by: nirnay_s
4 Replies

9. UNIX for Dummies Questions & Answers

Counting number of occurences

Hi All, I have to count the number of occurences of the character " ; " in a given line. I had used the following awk command to achieve the same echo $KOP.dat|awk '{split($1,my,";"); for(i in my)c++ }END{print c-1}' My file KOP.dat had the following data ... (1 Reply)
Discussion started by: kingofprussia
1 Replies

10. Linux

counting the number of lines

Hello, I have afile which begins with a few urls on multiple lines and then there is listing of some information on separate lines. The listing begins with the word Name on a given line followed by teh actual list. I want to count the number of lines in this file after the line having... (6 Replies)
Discussion started by: nayeemmz
6 Replies
Login or Register to Ask a Question