Find a Phrase in a File

Adriano Varoli Piazza moranar at gmail.com
Tue Sep 19 19:21:58 UTC 2006


2006/9/19, Gregory Piñero <gregpinero at gmail.com>:
> Hi there,
>
> I have a 56 mb text file, all the text on one line.  I want to find a
> certain phrase and show a few words before and after each occurance.
> Is there an easy way to do that on the command line that I'm
> overlooking?  grep just shows the whole line so that doesn't really
> help me.
>
> Let me know if you have any ideas.

Use fold (man fold) to wrap the text, then pipe it to grep.

-- 
Adriano Varoli Piazza
The Inside Out: http://moranar.com.ar
ICQ: 4410132
MSN: moranar at gmail.com




More information about the ubuntu-users mailing list