Find a word from multiple level files on Linux

 
Thread Tools Search this Thread
Operating Systems Linux Red Hat Find a word from multiple level files on Linux
# 1  
Old 06-08-2010
Find a word from multiple level files on Linux

To find a word from multiple level files:

"find . -type f -exec grep [word2find] {} +" is working on UNIX machines but not working on Linux machine. What is the equivalent command on Linux to find the word from multiple level files?

Input is appreciated.
# 2  
Old 06-09-2010
try this -

find ./ -name "*.*" | xargs grep <word_to_find>

here *.* represents ur file naming pattern. you can replace it with your requiremnt.
# 3  
Old 06-09-2010
maybe you try
find /home -name -exec grep "reg" {} \;
# 4  
Old 06-11-2010
Works on my RHEL and Xubuntu servers...

All three give same results... If there are a large number of files, I use pipe xargs for quicker responses.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Find a word and increment the number in the word & save into new files

Hi All, I am looking for a perl/awk/sed command to auto-increment the numbers line in file, P1.tcl: run_build_model sparc_ifu_dec run_drc set_faults -model path_delay -atpg_effectiveness -fault_coverage add_delay_paths P1 set_atpg -abort_limit 1000 run_atpg -ndetects 1000 I would like... (6 Replies)
Discussion started by: jypark22
6 Replies

2. Shell Programming and Scripting

Find command to find a word from list of files

I need to find a word '% Retail by State' in the folder /usr/sas/reports/RetailSalesTaxallocation. When I tried like below, -bash-4.1$ cd /usr/sas/reports/RetailSalesTaxallocation -bash-4.1$ find ./ -name % Retail by State find: paths must precede expression: Retail Usage: find ... (10 Replies)
Discussion started by: Ram Kumar_BE
10 Replies

3. Shell Programming and Scripting

awk to find lines containing word that occur multiple times

i have a script that scans a log file every 10 minutes. this script remembers the last line of the log and then uses it to continue monitoring the log when it runs again 10 minutes later. the script searches the log for a string called MaxClients. now, how can i make it so that when the... (7 Replies)
Discussion started by: SkySmart
7 Replies

4. Shell Programming and Scripting

Find and Move Files up One Level

Hi All, So I have another question. I'm trying to search for files with a certain extension and then move all of them up one level in the folder hierarchy. So something like this: original: /path/to/file/test.txt after: /path/to/test.txt I had some great help recently with another... (4 Replies)
Discussion started by: ideal2545
4 Replies

5. UNIX for Dummies Questions & Answers

Find EXACT word in files, just the word: no prefix, no suffix, no 'similar', just the word

I have a file that has the words I want to find in other files (but lets say I just want to find my words in a single file). Those words are IDs, so if my word is ZZZ4, outputs like aaZZZ4, ZZZ4bb, aaZZZ4bb, ZZ4, ZZZ, ZyZ4, ZZZ4.8 (or anything like that) WON'T BE USEFUL. I need the whole word... (6 Replies)
Discussion started by: chicchan
6 Replies

6. Shell Programming and Scripting

Find and replace a word in all the files (that contain the word) under a directory

Hi Everyone, I am looking for a simple way for replacing all the files under a directory that use the server "xsgd1234dap" with "xsdr3423pap". For Example: In the Directory, $pwd /home/nick $ grep -l "xsgd1234dap" *.sh | wc -l 119 I have "119" files that are still using... (5 Replies)
Discussion started by: filter
5 Replies

7. UNIX for Advanced & Expert Users

linux find and replace in multiple files

Is there a reason why all of these examples of linux find and replace in multiple files use find and grep to pipe into sed or perl. Why not just use sed or perl directly with something like this? sed -i 's/echo/burnbaby/g' booboo*... (2 Replies)
Discussion started by: cokedude
2 Replies

8. OS X (Apple)

how to find a string in file under multiple level dirs

Hi, i am asking a command to find a string in file(s) from multiple level directory structures. help would be really appreciated. (4 Replies)
Discussion started by: ywu081006
4 Replies

9. Shell Programming and Scripting

Searching a word in multiple files

Hi All, I have a issue in pulling some heavy records , I have my input file has 10,000 records which i need to compare with daily appended log files from (sep 1st 2009 to till date) . I tried to use grep fgrep and even sed , but the as time is factor for me , i cannot wait for 5 days to get the... (3 Replies)
Discussion started by: rakesh_411
3 Replies

10. UNIX for Dummies Questions & Answers

find files on first level folder

Hi: I have: folderA |----folderB |----folder1 |----folder2 |----folder3 |----folder3.1 Question: How can I find *.txt ONLY from /folderA/folderB/ and not the others folder1,2,3?? I tried: find... (8 Replies)
Discussion started by: iga3725
8 Replies
Login or Register to Ask a Question