Re: [SLUG] grep does not put the filename in front of every match

From: Alex Harris (nccuss17@gmail.com)
Date: Thu Mar 03 2005 - 07:09:39 EST


humm, which version of grep are you using, every instance I've tried
brings back the results I mentioned (only the first hit on a line has
the filename)?

version's I've used:
rh 9: 2.5.1
debian sarge: 2.5.1
cygwin: 2.5
-- Also, did you include the "o" after the H?

On Wed, 02 Mar 2005 18:41:37 -0500, Kwan Lowe <kwan@digitalhermit.com> wrote:
> Alex Harris wrote:
> > I am trying to search several hundred files for ip addresses.
> > These are text files with a bunch of words and the ip addresses are
> > interspered at random
> > Here are examples:
> > -----------file1-------------------
> > machine 1 is 10.30.41.6 and machine b is 192.168.3.6
> > machine c is 10.6.4.3 good to know machine 1 and b
> > ------------------------------------
> > -----------file2--------------------
> > machine 4 is 10.30.41.7 and machine b is 192.168.3.9
> > machine d is 10.6.4.3 and hates to know machine 1 and b
> > machine 5 is 10.30.41.3 and machine b is 192.168.3.0
> > --------------------------------------
> >
> > When I grep for the ip addresses the output is as follows:
> > file1:10.30.41.6
> > 192.168.3.6
> > file1:10.6.4.3
> > file2:10.30.41.7
> > 192.168.3.9
> > file2:10.6.4.3
> > file2: 10.30.41.3
> > Esentially grep will not put the filename in front of the second
> > occurance of an ip on a line.
> > I need a way to figure out how to have the filename be displayed on
> > the lines it's currently missing.
> >
> > In case it helps, the current grep command is:
> > egrep -Ho "[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}" *
>
> Odd... My grep will preface each line with the filename when I give the
> -H option as you have. Running your command on some random text files
> gives the filenames also.
>
> -----------------------------------------------------------------------
> This list is provided as an unmoderated internet service by Networked
> Knowledge Systems (NKS). Views and opinions expressed in messages
> posted are those of the author and do not necessarily reflect the
> official policy or position of NKS or any of its employees.
>
-----------------------------------------------------------------------
This list is provided as an unmoderated internet service by Networked
Knowledge Systems (NKS). Views and opinions expressed in messages
posted are those of the author and do not necessarily reflect the
official policy or position of NKS or any of its employees.



This archive was generated by hypermail 2.1.3 : Fri Aug 01 2014 - 20:15:25 EDT