Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

grep text in a binary file

Status
Not open for further replies.

unixwhoopie

Programmer
Joined
May 6, 2003
Messages
45
Location
US
I am trying to do a grep on a file, but I am always getting this message -

Binary file tmp.log matches.

I am giving the following command to search for 3038 and display all the lines in the file -
grep -40 '3038' tmp.log

I am kind of new to grep and trying to figure it out...

thanks
 
Maybe try...
Code:
strings tmp.log | grep -40 '3038'
That will pull the strings out of the binary file, then do the [tt]grep[/tt] on that.

Hope this helps.
 
Hi

If you are sure that tmp.log is text file, only [tt]grep[/tt] thinks that is binary, use the -a option :
man grep said:
-a, --text
Process a binary file as if it were text; this is
equivalent to the --binary-files=text option.

Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top