script to count a word in a flie


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers script to count a word in a flie
# 1  
Old 02-22-2008
Question script to count a word in a flie

hi All,

I have one question to have a answer with your help.

i need to have a script for searching a file with .log extension form all directories. search for a word " Pass" in the files and to count the occurence of the word "Pass".

i need all your help to solve the problem.

Thanks,
mohan
# 2  
Old 02-22-2008
find / -name "*.log" -exec grep -c "Pass" {} \;

Last edited by kanu_kanu; 02-22-2008 at 02:36 AM..
# 3  
Old 02-22-2008
Quote:
Originally Posted by kanu_kanu
grep -c "Pass" <file_name> will do
hi Kanu,

Thanks for your input.

as i am a new to scripting i request you to help me with full script. I do not know much about the scripting.

Thanks.
# 4  
Old 02-22-2008
this might be helpful to you
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

UNIX script to check word count of each word in file

I am trying to figure out to find word count of each word from my file sample file hi how are you hi are you ok sample out put hi 1 how 1 are 1 you 1 hi 1 are 1 you 1 ok 1 wc -l filename is not helping , i think we will have to split the lines and count and then print and also... (4 Replies)
Discussion started by: mirwasim
4 Replies

2. Shell Programming and Scripting

Word Count In A Script

I am in need of a basic format to 1. list all files in a directory 2. list the # of lines in each file 3. list the # of words in each file If someone could give me a basic format i would appreicate it ***ALSO i can not use the FIND command*** (4 Replies)
Discussion started by: domdom110
4 Replies

3. Shell Programming and Scripting

Script to count word occurrences, but exclude some?

I am trying to count the occurrences of ALL words in a file. However, I want to exclude certain words: short words (i.e. <3 chars), and words contained in an blacklist file. There is also a desire to count words that are capitalized (e.g. proper names). I am not 100% sure where the line on... (5 Replies)
Discussion started by: Cronk
5 Replies

4. Shell Programming and Scripting

Need script to count specific word and iterate over number of files.

Hi Experts, I want to know the count of specific word in a file. I have almost 600+ files. So I want to loop thru each file and get the count of the specific word. Please help me on achieving this... Many thanks (2 Replies)
Discussion started by: elamurugu
2 Replies

5. Shell Programming and Scripting

Word count of lines ending with certain word

Hi all, I am trying to write a command that can help me count the number of lines in the /etc/passwd file ending in bash. I have read through other threads but am yet to find one indicating how to locate a specifc word at the end of a line. I know i will need to use the wc command but when i... (8 Replies)
Discussion started by: warlock129
8 Replies

6. Shell Programming and Scripting

scripting - write a script that will count the number of times a particular word

hello everyone, I'm trying to learn some scripts but i cant get my head around two of them. 1. how can i write a script that will count the number of times a particular word is used in file? 2. how can i make a script that will take me to a web page from unix? if anyone could help it... (3 Replies)
Discussion started by: BigTool4u2
3 Replies

7. Fedora

word count wc

could someone explain this please. echo aaaa|wc -c 5 echo aaaa|wc -m 5 But I'd expect the count to be 4 Its SunOS 5.8 Thanks in Advance. (5 Replies)
Discussion started by: chaandana
5 Replies

8. UNIX Desktop Questions & Answers

trying to create a script to read a flie and loop a command...

I tried to explain this earlier, but did a poor job of it. So I am trying again but taking a different approach..... I have a file called test_words. In this file I have one line with 5 three letter words, with a single space seperating the words.(I.e., "cat car mop red pin") I want to... (5 Replies)
Discussion started by: Italy87
5 Replies

9. UNIX for Advanced & Expert Users

trying to create a script to read a flie and loop a command...

Tried to explain this earlier, but did a poor job of it. So I am trying again but taking a different approach..... I have a file called test_words. In this file I have one line with 5 three letter words, with a single space seperating the words.(I.e., "dog car mop red pin") I want to create a... (1 Reply)
Discussion started by: Italy87
1 Replies

10. UNIX for Dummies Questions & Answers

count word

hi, given a file i need to get the first line and secodn line and count each of the line whether the length of first line and second line is the same i don;t know how to get the length of the line...seems like use 'wc' cannot do it... please advice (1 Reply)
Discussion started by: ariuscy
1 Replies
Login or Register to Ask a Question