[wellylug] Is there a good way to....

Wood Brent pcreso at pcreso.com
Thu Jan 29 18:49:06 NZDT 2004


 
Enkidu wrote:

> Is there a good way to drop lines from a file or do I have to do 
> something like

simplest way for a text file (that I know of), is grep.

Normally this returns lines which match the pattern you specify, but the -v
option reverses this to drop lines which match the pattern.

If you have a few patterns, which do not easily fit a single regexp, just pipe
the output through successive grep -v commands in a single statement to filter
them all out.

Summat I like with this approach is that you can omit the -v on the first
invocation of the whole statement, to get as output the line that will be
deleted. A very useful check to run before sticking in the -v & deleting them.


Hope this helps,

  Brent Wood




More information about the wellylug mailing list