Re: quickie UNIX command

Subject: Re: quickie UNIX command
From: Hollis Blanchard (
Date: Thu May 17 2001 - 10:58:28 MDT

On Thu, May 17, 2001 at 01:06:32PM -0400, cdowns wrote:
> cat <filename> | grep -v "string_name" >> <newfile>
> and it will be stripped and a new file created .

Two comments:
This is the most common abuse of 'cat'. 'grep -v "string" < file > newfile'
works great.

Appending ('>>') isn't necessary... grep may operate line-by-line, but it all
goes to stdout (which the shell has reassigned to land in 'newfile').

And a warning: never try to read from and write to the same file at the same
time. In the command I listed, if 'file' and 'newfile' are the same, you will
magically transform it into a 0-byte file.


This archive was generated by hypermail 2a24 : Thu May 17 2001 - 10:23:21 MDT