Mailing List Archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [tlug] grep sort of thing



Brett Robson <b-robson@example.com> wrote:
> > > > 
> > > > I want to display strings from a text file(s) based on a reg exp, sort
> > > > of like egrep but only displaying the matched string not the whole line
> > > > from the file.
> 
> No, the search expression is a regular expression so it may be different
> each match, in this case it /will/ be different each time.
> 
> I think Bruce's idea is the better than anything I've come up with.

Yes, but you don't need grep for that.  This only matches 1 pattern each
line though.

    sed -n 's/^.*\(regexp\).*$/\1/p' file

Stephen


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links