- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- recursive grep
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2001 09:30 AM
11-12-2001 09:30 AM
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2001 09:33 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2001 09:35 AM
11-12-2001 09:35 AM
Re: recursive grep
# cd thedirectory
# find . -type -f -print | xargs grep string
This will recursively search the current directory and all subdirectories looking for *files* only which contain the the string "string". The use of 'xargs' in lieu of '-exec' with the the 'find' utility is less resource intensive.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2001 09:36 AM
11-12-2001 09:36 AM
Re: recursive grep
-raj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2001 09:42 AM
11-12-2001 09:42 AM
Re: recursive grep
Also, if you know that the file is less than say 1mb (1000000) then you can add that knowledge to "find":
find /searchdir -type f -size -1000000c -exec grep -l {} \;
If you aren't sure about case add the "i" option to the grep:
find /searchdir -type f -size -1000000c -exec grep -il {} \;
live free or die
harry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2001 12:15 PM
11-12-2001 12:15 PM
Re: recursive grep
alias regrep="find . -type f | xargs file | grep text | grep -v awk|sed 's/://' | cut -f 1| xargs grep -i"
Yes, it's a bit convoluted (thus the alias), but it works.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2001 03:36 PM
11-12-2001 03:36 PM
Re: recursive grep
The other trick I do is:
find . -type f | xargs grep string /dev/null
You know /dev/null can *never* contain the string...but, since the grep now has more than one filename in its file list, it will print the matching line + the name of the matching file.
Rgds, Robin