find keyword


 
Thread Tools Search this Thread
Operating Systems Solaris find keyword
# 1  
Old 04-15-2010
find keyword

Hi,

This is my first post.

Please help me.
I wanted to find a particular key word in the entire system not in the filename, it should be in the file content.
The output should display me...

<The filename>, number of times the keyword is repeated.

like

file1: 2
file2: 4
file3: 6
file4: 8

Here, I wanted to do a case insensitive search and the keyword can be anywhere in the word like if i wanted to search 'cat', caterpilli,pillCAtaaa are to be dispalyed.

Regards,
Pointers.
# 2  
Old 04-15-2010
use find and grep to do that. read man pages of
Code:
find

and
Code:
grep

# 3  
Old 04-15-2010
Hi,

To find the files with the string you desire,this will list all the files that has the below string. Now to match it exactly to your requirement , let me think ..if i get it i will post it.

Code:
find / -name "*.*" -exec fgrep -l "caterpilli" {} \;


This works for me , to find all files that has the string "/SFS"

Code:
find /export/opt -name "*.log" -exec fgrep -l "/SFS" {} \;

Thanks.

---------- Post updated at 01:16 PM ---------- Previous update was at 12:44 PM ----------

From man pages ,

grep -c will give count of the lines that matches t string, -i will ignore case. I don't have a shell now ,so i can't test it.

Code:
find / -name "*.*" -exec fgrep -lci "caterpilli" {} \;

Thanks

Last edited by Franklin52; 04-15-2010 at 05:33 AM.. Reason: Please use code tags, thank you!
# 4  
Old 04-16-2010
HTML Code:
find . -name "*ca*" -print ; sudo find . -name "*CA*" -print
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Search for a Keyword in file and replace another keyword or add at the end of line

Hi I want to implement something like this: if( keyword1 exists) then check if(keyword2 exists in the same line) then replace keyword 2 with New_Keyword else Add New_Keyword at the end of line end if eg: Check for Keyword JUNGLE and add/replace... (7 Replies)
Discussion started by: dashing201
7 Replies

2. Shell Programming and Scripting

Find keyword and export

I was trying to do any keyword search against all files in a particular folder, and interested in finding, an particular "keyword" whether present, if it present I need to export that file to an new folder. How to do it , via simple script ? (3 Replies)
Discussion started by: Jose Nirmal
3 Replies

3. Shell Programming and Scripting

paste a keyword

Hello, I have a file with a keyword ccas i want to copy the keyword once in VI and have to paste it in the same file for multiple time,let's say 700 times,i dont know hoe to do it. Kindly help me on this Regards Thelak (2 Replies)
Discussion started by: thelakbe
2 Replies

4. Shell Programming and Scripting

find keyword from file and search in another file

hi dudes; this is my file.txt:20101228-180436_Down a 1 b 2 ... 20101228-190436_Rollback a 1 40 e 3 20 ... 20101228-180436_Down c 2 f 2 c 1 ... and i have a down.txt:a 1 aa 2 30 bb 1 40 b 2 ab 3 10 c 3 cd 4 50 ac 2 20 c 3 ad 1 0 (2 Replies)
Discussion started by: gc_sw
2 Replies

5. UNIX for Dummies Questions & Answers

how to find a word in a file that appears next to a given keyword

Hi Experts, I have a file which contains some text. i need to print the word next to a given keyword. Please help. Ex: test.txt ===================== NEXT HOST ===================== AEADBAS001 access-list 1 permit xxxxxxxxxxxxxx ip access-list extended BLA_Outgoing_Filter... (6 Replies)
Discussion started by: mwrg
6 Replies

6. OS X (Apple)

Keyword Searching

Hi all, I am in the process of building a shell script as part of a auditing utility. It will search a specified directory for keywords and output results of the file path, and line number that the word was found on. I built a test script (shown below) that does just this, but egrep apparently... (0 Replies)
Discussion started by: tmcmurtr
0 Replies

7. UNIX for Dummies Questions & Answers

Using $0 and 'Function' Keyword

Hi all, I had a query on the usage of $0 in shells. I would appreciate any assistance in this. We moved from a sun solaris server to a linux server. I ran 2 different pieces on these servers and in one case, the outputs didnt change and in the other case, the outputs were different. The 2... (3 Replies)
Discussion started by: novice1324
3 Replies

8. Shell Programming and Scripting

display (ehco) 5 lines before and after find keyword

I like to display 5 lines before and after find some keywork (i.e. error). Thanks in advance (5 Replies)
Discussion started by: wangzosen
5 Replies

9. Programming

Far Keyword

Hello, What is far keyword in C and for what purpose is it used??? Pls ans. thanx in advance. svh (2 Replies)
Discussion started by: svh
2 Replies

10. Shell Programming and Scripting

Keyword in perl

Hi, I want to know all the keywords in perl as well as their usage. plz provide if u have any URL regarding this. In my perl script first 2 lines are 1)use DBI; 2)require "hello.pl"; what is the use these two statements. i thought the second one may be like include . Thanks in advance.... (1 Reply)
Discussion started by: sarwan
1 Replies
Login or Register to Ask a Question