Need a perl script similiar to grep -r 'word' /path/to/dir"


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need a perl script similiar to grep -r 'word' /path/to/dir"
# 1  
Old 10-21-2012
Network Need a perl script similiar to grep -r 'word' /path/to/dir"

Hi ,

i am looking for a perl script to grep for a string in all files inside a directory .

bash command .
Code:
grep -r 'word' /path/to/dir

Thanks,
Nvil

Last edited by Franklin52; 10-22-2012 at 03:07 AM.. Reason: Please use code tags for data and code samples
# 2  
Old 10-21-2012
# 3  
Old 10-21-2012
Hi.

There is a grep work-alike written in perl at http://cpansearch.perl.org/src/CWEST...rc/grep/tcgrep It includes a recursive option.

Best wishes ... cheers, drl
# 4  
Old 10-21-2012
Why do you need perl for this?
Use grep with find.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

"find . -printf" without prepended "." path? Getting path to current working directory?

If I enter (simplified): find . -printf "%p\n" then all files in the output are prepended by a "." like ./local/share/test23.log How can achieve that a.) the leading "./" is omitted and/or b.) the full path to the current directory is inserted (enclosed by brackets and a blank)... (1 Reply)
Discussion started by: pstein
1 Replies

2. UNIX for Dummies Questions & Answers

Script to search for a particular word in files and print the word and path name

Hi, i am new to unix shell scripting and i need a script which would search for a particular word in all the files present in a directory. The output should have the word and file path name. For example: "word" "path name". Thanks for the reply in adv,:) (3 Replies)
Discussion started by: virtual_45
3 Replies

3. Shell Programming and Scripting

Finding a "word" through grep but display line above?

Hi guys. I am trying to perform a search using grep. I get my grep to work, but need to "awk" a Process Number that is 2 lines above... Example: I run a query on my TSM server for Processes that are "Waiting" for something...it returns this: Process Number: 32,881 Process... (14 Replies)
Discussion started by: Stephan
14 Replies

4. UNIX for Dummies Questions & Answers

grep for a last word from a path

Hi , I want to get the last word from a path. Example:: I have path:: /TEMP_REGRESSION/regression/TESTSUITE/TestCases/Test1201/ext_libs/DATA/INTERNAL/pad_ext.lef I want the last word only.ie pad_ext.lef Please let me know how to grep that word. Thanks in advance (6 Replies)
Discussion started by: gujrathinr
6 Replies

5. UNIX for Dummies Questions & Answers

How to check multi word in the same script for all dir ?

I want to check two different words are present in the same script and the words are, 1. message 2. 'error' - here {search word - including single quote} How to check in UNIX from current & sub directories or from root to all dir + sub directories ? Please advice. Thanks! (1 Reply)
Discussion started by: gkskumar
1 Replies

6. Homework & Coursework Questions

How to use a execvp-call to do "grep PATH"?

Hello! I am learning how to use the function execvp. I have read through the UNIX manual. I have a process. I run execvp and I command it to do “printenv”. It works fine. Before I do the execvp-call I pipe STDOUT to go to a specific pipe. After that I restore STDOUT. I read that pipe in another... (2 Replies)
Discussion started by: andersbranderud
2 Replies

7. AIX

rsh server "script..." which $PATH is used ?

When running a script on a distant server via rsh, what is the $PATH used ? I had done a script in the /usr/local/bin but the rsh reported it did not find it. So I assume it is using a separate $PATH but how can I find out ? (1 Reply)
Discussion started by: Browser_ice
1 Replies

8. Shell Programming and Scripting

How do I define a particular dir in PATH variable and then unset that dir

How do I define a particular dir in front of PATH variable and then run some job and then at the end of job SET the PATH variable to original? in a script, WILL something like this work: ORIG_PATH=$PATH export PATH=/dir1/dir2:$PATH RUN SOME JOBS ..... unset PATH EXPORT... (2 Replies)
Discussion started by: Hangman2
2 Replies

9. Shell Programming and Scripting

grep for "exact word"

Hi All, Very GM I am searching for a specific filesystem on a serevr, like df -k "/" i am geting an output also... but when i am checking for somthing like /oramnt (which is not mounted currently) so i am geting an out like this df -k "/oramnt" output of root...! so i tried... (7 Replies)
Discussion started by: bullz26
7 Replies

10. Shell Programming and Scripting

grep all records in a file and get a word count -perl

Hi, I have a file .. file.txt .. i need to get a total record count in the files into a $variable.. im using perl script thanks (4 Replies)
Discussion started by: meghana
4 Replies
Login or Register to Ask a Question