Click here to Skip to main content
13,050,429 members (80,370 online)
Rate this:
Please Sign up or sign in to vote.
See more:

I want to write a shell script that searches the file contents in a directory and its subdirectories for a text string given by the user. It list all such file names having the given string and the store in a temp file "abc".

Posted 4-Aug-12 19:54pm
Sandeep Mewara 5-Aug-12 2:36am
And the issue is?

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Using the find[^] command combined with grep[^] should do it. It's a long time since I wrote find scripts so I cannot come up with a sample off the top of my head, but it will be something like:
find . -name -exec grep "pattern" {} \;

added -name which I think is necessary.
Mohibur Rashid 5-Aug-12 10:21am
an example for grep is :
$ grep -r "redeem reward" specific_directory_path
Richard MacCutchan 5-Aug-12 12:48pm
Not when it's part of a find command as above.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.170713.1 | Last Updated 5 Aug 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100