Script to find a string in a directory/sub-directory


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Script to find a string in a directory/sub-directory
# 1  
Old 11-12-2008
Script to find a string in a directory/sub-directory

I'm trying to find this string 'preparing string IBE_Quote_W1_Pvt.SaveWrapper for quote_header_id’ in my Apache log file directory. The log file that contains this string may be in a parent direcotry or a sub-directory. I have tried 'grep' and 'awk' with no success.

I would like to get the path plus filename in the output.

Anyone got any ideals.?

Thanks

"G"

Last edited by gross; 11-12-2008 at 05:34 PM.. Reason: Clarification
# 2  
Old 11-13-2008
try:
Code:
find /path/to/apache_log_dir -type f | xargs grep -i 'preparing string IBE_Quote_W1_Pvt.SaveWrapper for quote_header_id'

# 3  
Old 11-13-2008
Quote:
Originally Posted by Yogesh Sawant
try:
Code:
find /path/to/apache_log_dir -type f | xargs grep -i 'preparing string IBE_Quote_W1_Pvt.SaveWrapper for quote_header_id'

Or we can use the -exec with find

Code:
find /path/to/apache_log_dir -name "*" -type f -exec grep -i 'preparing string IBE_Quote_W1_Pvt.SaveWrapper for quote_header_id' {} \;

# 4  
Old 11-13-2008
Thanks

Thanks.

Both suggested scripts worked well.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to find and get a file in an entire directory with an excluded directory specified?

How to get a file 'zlib.h' in an entire directory with an excluded directory specified lives under that starting directory by using find command, as it failed on: $ find . -name 'zlib.h' -a -ipath 'CHROME.TMP' -prune -o -print it'll just list entirely up (2 Replies)
Discussion started by: abdulbadii
2 Replies

2. Shell Programming and Scripting

Shell scripting-I need a script which should watch a directory for a file with specific directory

I need a script which should watch a directory for a file with specific directory. If it finds a file in directory, it should search for few specific keyword in the file. if the keyword exists, it should trim string from specific column. The file should be moved to another directory and the a... (8 Replies)
Discussion started by: akashdeepak
8 Replies

3. Shell Programming and Scripting

Find every directory named XYZ under the DVLP directory

I only want to find files under each branch of the directory tree inside directories named XYZ and there are multiple XYZ directories? (7 Replies)
Discussion started by: emc^24sho
7 Replies

4. Shell Programming and Scripting

HPUX find string in directory and filetype and replace string

Hi, Here's my dilemma. I need to replace the string Sept_2012 to Oct_2012 in all *config.py files within the current directory and below directories Is this possible? Also I am trying to find all instances of the string Sept_2012 within files in the current directory and below I have... (13 Replies)
Discussion started by: pure_jax
13 Replies

5. UNIX for Dummies Questions & Answers

How to Find a String in Each File in a Directory

Hi, I have the ff. list of files in the dir named /home/joule/unix/archive: $ /home/joule/unix/archive joule1.gz joule2.gz joule3.gz joule4.gz joule5.gz joule6.gz joule7.gz joule8.gz What I would like to do is to find this string in a group of files in the directory above: String to... (1 Reply)
Discussion started by: Joule
1 Replies

6. Shell Programming and Scripting

How to find particular string in multiple files with in the current directory.

Hello friends, Plz suggest the find command, How to search a string in a paticular string in miltiple files with current dirctory.:) Thanks in advance. Siva Ranganath Ch (2 Replies)
Discussion started by: sivaranga001
2 Replies

7. Shell Programming and Scripting

Find a string under a directory that is contained in another file

Hi I am loking for some help in writing a script that will take a number that is located in one file and search a folder structure for that string in any file under that directory. I can do this manually with : find /"directory" -type f -exec grep -l 'Number String' {} \; But now I will... (3 Replies)
Discussion started by: BMC
3 Replies

8. Shell Programming and Scripting

find and replace string in a directory files

Hi, I have a directory has DIR1 and the D1 directory has 200+ files. I want change the string from "Bangalore" to "Bangaluru" in all files in the D1 directory. Thanks (2 Replies)
Discussion started by: koti_rama
2 Replies

9. UNIX for Dummies Questions & Answers

Unix find command to print directory and search string

Hi i need to print pathname in which the string present using 'find' command sample output like this Pathname String to be searched ---------- -------------------- /usr/test/myfile get /opt/test/somefile get Thanks in... (4 Replies)
Discussion started by: princein
4 Replies

10. AIX

Help Using Grep command to Find the string in the files in the root directory

I want to serch for a string in all the files in the root directory. i want the search to be limited to only the files in the directory i.e the search to be done only in the files not in the sub directory. the approaches tried are 1)grep "pattern string" this command was serching the... (3 Replies)
Discussion started by: Subbu_Angeline
3 Replies
Login or Register to Ask a Question