Pipe binary file matches grep results to file


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Pipe binary file matches grep results to file
# 1  
Old 01-23-2012
Pipe binary file matches grep results to file

I am using grep to match a pattern, but the output is strange.

Code:
$ grep -r -o "pattern" *

Gives me:
Code:
Binary file foo1 matches
Binary file foo2 matches
Binary file foo3 matches

To find the lines before/after, I then have to use the following on each file:
Code:
$ strings foo1 | grep -A1 -B1 "pattern"

How can I recursively perform this operation with strings? Or, is there an alternative?
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Replace string of a file with a string of another file for matches using grep,sed,awk

I have a file comp.pkglist which mention package version and release . In 'version change' and 'release change' line there are two versions 'old' and 'new' Version Change: --> Release Change: --> cat comp.pkglist Package list: nss-util-devel-3.28.4-1.el6_9.x86_64 Version Change: 3.28.4 -->... (1 Reply)
Discussion started by: Paras Pandey
1 Replies

2. Shell Programming and Scripting

Convert binary file to csv and then back to the binary format

Hello *nix specialists, Im working for a non profit organisation in Germany to transport DSL over WLAN to people in areas without no DSL. We are using Linksys WRT 54 router with DD-WRT firmware There are at the moment over 180 router running but we have to change some settings next time. So my... (7 Replies)
Discussion started by: digidax
7 Replies

3. Shell Programming and Scripting

sed returns different results while substitution on a pipe delimited file

Hi, Need help with a sed command that I am using to substitute 3 positions of a pipe delimited file. i am getting different results while substituting the same position of two different files with the same value. Please see details below: $ cat chk2 ... (3 Replies)
Discussion started by: vmenon
3 Replies

4. UNIX for Dummies Questions & Answers

Write to file using tail -f through a pipe to grep

Hi -- I'm looking to write to a file after piping output from tail -f through to grep: #write to a file for all lines with "searchtext" within in error_log: Expand|Select|Wrap|Line Numbers tail -f /var/error_log | grep searchtext > output.txt The above command... (2 Replies)
Discussion started by: ndedhia1
2 Replies

5. Shell Programming and Scripting

Grep on a binary file

Hi everyone. I have a binary file in wich there is a date with format DDMMMYY, for example 02May09. I can see it opening this file with vim: inside a binary mess, I can clearly read that string. Now: do you know a way to extract this string from the file? I woul like to do something... (14 Replies)
Discussion started by: canduc17
14 Replies

6. UNIX for Dummies Questions & Answers

Pipe results of Grep Command to LS Comand

I'm using the command grep -l XYZ to get a list of files containing the string XYZ. Then I using the comand ls -l ABC to get the create date timestamp of the each file. I've tried combining the comands using the pipe command, grep -l XYZ | ls -l, but its not working. What am I doing wrong? (3 Replies)
Discussion started by: jhtate
3 Replies

7. Shell Programming and Scripting

Grep for NULL in a pipe delimited file

hi, How can I check for a field in a pipe-delimited file having a NULL value in Unix using a grep command or any other command. Please reply (5 Replies)
Discussion started by: sureshg_sampat
5 Replies

8. Shell Programming and Scripting

Pipe Data From Grep Into A File

I am somewhat of a novice at unix scripting and I need a little help. Here is what im trying to do: I am trying to figure out how to pipe the following grep results into a file. /source/programs: grep "WSBL020" W* WBMB991.cbl: COPY WSBL020. WDCB003.cbl: COPY... (4 Replies)
Discussion started by: katinicsdad
4 Replies

9. Solaris

compiled binary file gives "cannot execute binary file"

Hi, I have two Solaris machines. 1. SunOS X 5.8 Generic_108528-29 sun4u sparc SUNW,Sun-Blade-1500 2. SunOS Y 5.8 Generic_108528-13 sun4u sparc SUNW,Ultra-60 I am trying to buiild a project on both these machines. The Binary output file compiled on machine 2 runs on both the machines. Where... (0 Replies)
Discussion started by: scgupta
0 Replies

10. UNIX for Dummies Questions & Answers

Filter results through pipe with grep

ls -ltr | grep string How can I use regular expressions to filter the results provided even more. I am using the above command as a reference. (1 Reply)
Discussion started by: ckandreou
1 Replies
Login or Register to Ask a Question
ZGREP(1)						    BSD General Commands Manual 						  ZGREP(1)

NAME
zgrep, zegrep, zfgrep -- print lines matching a pattern in gzip-compressed files SYNOPSIS
zgrep [grep-flags] [--] pattern [files ...] zegrep [grep-flags] [--] pattern [file ...] zfgrep [grep-flags] [--] pattern [file ...] DESCRIPTION
zgrep runs grep(1) on files or stdin, if no files argument is given, after decompressing them with zcat(1). The grep-flags and pattern arguments are passed on to grep(1). If an -e flag is found in the grep-flags, zgrep will not look for a pattern argument. zegrep calls egrep(1), while zfgrep calls fgrep(1). EXIT STATUS
In case of missing arguments or missing pattern, 1 will be returned, otherwise 0. SEE ALSO
egrep(1), fgrep(1), grep(1), gzip(1), zcat(1) AUTHORS
Thomas Klausner <wiz@NetBSD.org> BSD
December 28, 2003 BSD