grep a string on all files in the subdirectories


 
Thread Tools Search this Thread
Operating Systems Solaris grep a string on all files in the subdirectories
# 1  
Old 05-15-2007
grep a string on all files in the subdirectories

Hi all,

I would want to find a string 'abc' on all files which is located under a directory.

But inside the directory there are subdirectories, so how can I find whether 'abc' exists on all files in the subsequent subdirectories?

Thanks.
# 2  
Old 05-15-2007
Code:
find /path/to/directory -exec grep "abc" {} /dev/null \;

This User Gave Thanks to vino For This Post:
# 3  
Old 05-15-2007
I would do it this way if you want to verify all files to reduce the output.

Code:
find /path/to/directory -exec grep -c "abc" {} /dev/null \;

# 4  
Old 05-15-2007
Vino & reborg, thanks a lot for the statement.
# 5  
Old 05-15-2007
grep -Rl string /path/to/dir

not available on all systems
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Append string to all the files inside a directory excluding subdirectories and .zip files

Hii, Could someone help me to append string to the starting of all the filenames inside a directory but it should exclude .zip files and subdirectories. Eg. file1: test1.log file2: test2.log file3 test.zip After running the script file1: string_test1.log file2: string_test2.log file3:... (4 Replies)
Discussion started by: Ravi Kishore
4 Replies

2. Shell Programming and Scripting

Unzip all the files with subdirectories present and append a part of string from the main .zip files

Hi frnds, My requirement is I have a zip file with name say eg: test_ABC_UH_ccde2a_awdeaea_20150422.zip within that there are subdirectories on each directory we again have .zip files and in that we have files like mama20150422.gz and so on. Iam in need of a bash script so that it unzips... (0 Replies)
Discussion started by: Ravi Kishore
0 Replies

3. Shell Programming and Scripting

Grep string in files and list file names that contain the string

Hi, I have a list of zipped files. I want to grep for a string in all files and get a list of file names that contain the string. But without unzipping them before that, more like using something like gzcat. My OS is: SunOS test 5.10 Generic_142900-13 sun4u sparc SUNW,SPARC-Enterprise (8 Replies)
Discussion started by: apenkov
8 Replies

4. Shell Programming and Scripting

grep exact string from files and write to filename when string present in file

I am attempting to grep an exact string from a series of files within a directory and append that output to the filename when it is present in the file. I've been after this all day with no luck. Thanks for your help in advance :wall:. (4 Replies)
Discussion started by: JC_1
4 Replies

5. Shell Programming and Scripting

Script to find & replace a multiple lines string across multiple php files and subdirectories

Hey guys. I know pratically 0 about Linux, so could anyone please give me instructions on how to accomplish this ? The distro is RedHat 4.1.2 and i need to find and replace a multiple lines string in several php files across subdirectories. So lets say im at root/dir1/dir2/ , when i execute... (12 Replies)
Discussion started by: spfc_dmt
12 Replies

6. Programming

Help to grep string in log files

hello guys.., i have some problem with grepping strings in log files.. so..,i need an java logic on how to grep srtings in log files the output must be in gui.., please help me .. regards raghuraipur:confused: (1 Reply)
Discussion started by: raghuraipur
1 Replies

7. Shell Programming and Scripting

Replace a string in all files under a directory and its subdirectories

Hello Friends, I've been trying to write a script which finds a string and change it with another string. For this i want to search all files (with its arguments) under a spesific directory and its subdirectories. For example lets assume i want to replace an IP= 192.168.0.4 with another... (4 Replies)
Discussion started by: EAGL€
4 Replies

8. Shell Programming and Scripting

search in all subdirectories for a file containing a certain string

Hello, how can I search a directory AND all its subdirectories for a file containing a certain string? My directories contain too many sql-files and I want to know whcih one of them write into the table "customer"? Can anyone help me? Thanks in advance (1 Reply)
Discussion started by: ABE2202
1 Replies

9. Shell Programming and Scripting

grep a string from 2 text files

How to grep a string in two different files, I am having the following scenario TextFile1 Date (dd/mm)Time Server IP Error Code =========================================================================== 10/04/2008 10:10 ServerA xxx.xxx.xxx.xxx ... (15 Replies)
Discussion started by: karthikn7974
15 Replies

10. UNIX for Dummies Questions & Answers

to grep and rm including all subdirectories

Is there a way to grep a word pattern in all files under all subdirectories? Similar question with rm. To remove files with certain extension in all subdirectories? Thanks to all who reply! (1 Reply)
Discussion started by: annej33
1 Replies
Login or Register to Ask a Question