- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- easy unix searching question
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
08-20-2001 10:42 AM
08-20-2001 10:42 AM
Thanks in advance...
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-20-2001 10:47 AM
08-20-2001 10:47 AM
Re: easy unix searching question
You could try something like
find /path -type f -exec grep 'string' {} \;
where path is the directory and string is the word you are looking for.
If you are looking for a word in text files which are located in the same directory, you could try something more simpler like
grep 'word' *
-HTH
Ramesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-20-2001 10:54 AM
08-20-2001 10:54 AM
Solutionfind /path -type f -exec grep -i "string" {} \;
If you want the filenames, you can add the "-l" (as in lower case L) to the grep command. If you suspect the file size to be less than 1Meg, you can add the "-size -1000000c" to the find command, as in:
find /path -type f -size -1000000c -exec grep -il "string" {} \;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-20-2001 11:31 AM
08-20-2001 11:31 AM
Re: easy unix searching question
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2001 09:16 AM
08-21-2001 09:16 AM
Re: easy unix searching question
The -type f to find will be true on executable file as well. This may cause some gibberish output from the grep command. To get around this create a small scrip called is_text
with the following line:
file $1 | grep -q text
then chmod your script and invoke find:
find /path -type f -exec is_text {} \; -exec grep -il {} /dev/null \;
The /dev/null is a trick to force grep to report the filename.
lzc