Operating System - HP-UX
1833847 Members
2348 Online
110063 Solutions
New Discussion

Searching A File Without Having To Open It

 
Andrew Kaplan
Super Advisor

Searching A File Without Having To Open It

One of our servers has a large mail.log file that I would like to search for a specific string. Is there a command that I can use to do so without having to open the file first? Thanks.
A Journey In The Quest Of Knowledge
3 REPLIES 3
Pete Randall
Outstanding Contributor

Re: Searching A File Without Having To Open It

grep 'string' filename

Pete

Pete
harry d brown jr
Honored Contributor

Re: Searching A File Without Having To Open It

Sorry, but all commands are going to "open" the file, it's just the way it works.

Try "grep"

grep STRING filename

Waht are you trying to "extract" from the mail.log file?

live free or die
harry
Live Free or Die
Stanimir
Trusted Contributor

Re: Searching A File Without Having To Open It

cat ./mail.log | grep "string" | more