- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- faster 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
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
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
тАО04-23-2007 02:09 AM
тАО04-23-2007 02:09 AM
faster grep
I have a few big log files for which I need to grep for a certain set of characters, but grep takes a long time finding them . Can it be done faster with another tool.
I need a faster equivalent of :
grep "log message" *
thanks,
hunki
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-23-2007 02:22 AM
тАО04-23-2007 02:22 AM
Re: faster grep
most of the system utils (such as grep) are already pretty fast!
But, try an exact match:
If you are on 11.11 onwards
grep -E "(^|[^[:alnum:]_])(
or gnu grep -w option
Another way would be to split the file and then run parallel greps against the segments, but I suspect the split would actually take longer than your grep.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-23-2007 02:23 AM
тАО04-23-2007 02:23 AM
Re: faster grep
Now the smarter way to do what you are trying to do is to keep up with the last position searched in the file and do your searches from 1 character past the old end of file to the current end of file. You then record the current end of file and it becomes the new starting position for the next search. If the current end position is greater than the stored end position then the file has been rewritten and you need to start at the beginning. This would be rather straightforward in Perl.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-23-2007 02:35 AM
тАО04-23-2007 02:35 AM
Re: faster grep
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-23-2007 02:44 AM
тАО04-23-2007 02:44 AM
Re: faster grep
Most likely the bottleneck is I/O capacity, and more specifically the sustained read speed of your disk(s): if you want it done faster, you'll need to have the logs stored on a faster storage system.
Another possible bottleneck would be CPU, if you have an old server with a fast FibreChannel storage.
MK
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-23-2007 02:51 AM
тАО04-23-2007 02:51 AM
Re: faster grep
Split the log files so you get smaller log files so you searching through only the specific information you are after
or
try keeping track of the size of the log file and only monitor new lines. See attached file for example of this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-23-2007 02:59 AM
тАО04-23-2007 02:59 AM
Re: faster grep
I would employ logrotate for that job,
which does keep as many rotated generations
as you specify and compresses them or does other post processing that you deem necessary.
Also you are free to define any pre or post processing commands that may be appropiate to make the log writing process release the log and continue with the new one.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-23-2007 03:11 AM
тАО04-23-2007 03:11 AM
Re: faster grep
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-23-2007 05:20 PM
тАО04-23-2007 05:20 PM
Re: faster grep
One user was complaining that grep on HP-UX was slower than on OpenVMS. Years ago, someone from the commands group was telling us how they made grep about as fast as fgrep with some new algorithms. (Match from right to left.) So I don't know how HP-UX is slower?
>But, try an exact match: grep -E
This will only make things slower, unless you are worried about the time to output the matches. As Clay says, fgrep should be faster.
>I was searching through some archived logs files as well.
Well, you could do:
$ find . -mtime -2 -exec grep "log message" +
(Search for all files modified in the last 2 days.)