- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: multiple grep 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
03-12-2003 02:43 AM
03-12-2003 02:43 AM
I have approx. 6000 files & want to search for about 7 different numeric strings. Any ideas how this could be done?
Regards,
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2003 02:48 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2003 02:48 AM
03-12-2003 02:48 AM
Re: multiple grep question
find
If you only want to know which files contain one of the strings, supply the -l flag to grep.
Regards,
John
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2003 02:53 AM
03-12-2003 02:53 AM
Re: multiple grep question
A number of ways exist, depending on where your files are located. If they're all in one directory, then:
grep -e 123 -e 456 -e 789 *
or
grep -E '(123|456|789)' *
or
create a file, say /tmp/strings containing the search strings and:
grep -f /tmp/strings *
If the files are in subdirectories, then:
find /dir -type f | xargs grep -E '(123|456|789)'
or any of the other greps above.
rgds, Robin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2003 02:54 AM
03-12-2003 02:54 AM
Re: multiple grep question
I use a script called findgrep:
case $# in
1) cat /tmp/filelist | grep $1 ;;
2) cat /tmp/filelist | grep $1 | grep $2 ;;
3) cat /tmp/filelist | grep $1 | grep $2 | grep $3 ;;
4) cat /tmp/filelist | grep $1 | grep $2 | grep $3 | grep $4 ;;
5) cat /tmp/filelist | grep $1 | grep $2 | grep $3 | grep $4 | grep $5 ;;
*) echo " Thats much parameters " ;;
esac
It makes use of a file /tmp/filelist. This file is made by a cron job which performs: find / -print > /tmp/filelist
Thsi way the findgrep works very fast.
HTH
Donald
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2003 02:55 AM
03-12-2003 02:55 AM
Re: multiple grep question
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2003 02:55 AM
03-12-2003 02:55 AM
Re: multiple grep question
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2003 02:56 AM
03-12-2003 02:56 AM
Re: multiple grep question
cd /dir
find . -name "file pattern" -exec grep -e string -e string.
Modify your grep with:
-i = case insensative
-v = omit
For example, your string has upper and lower case char.s:
cd /dir
find . -name "file pattern" -exec grep -i -e string -e string.
For example, you want to eliminate everything and take the remainder:
cd /dir
find . -name "file pattern" -exec grep -v -e string -e string.
For example, your string has upper and lower case char.s AND you want to eliminate everything and take the remainder:
cd /dir
find . -name "file pattern" -exec grep -i -v -e string -e string.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2003 02:58 AM
03-12-2003 02:58 AM
Re: multiple grep question
cd /dir
find . -name "file pattern" -exec grep -v -e string -e string {} \;
NOTE the end of all find is {} \;
(* I hate that when it happens. :-) *)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2003 03:24 AM
03-12-2003 03:24 AM
Re: multiple grep question
Thanks for the GREAT info!!
Regards,