Help with batch file.

Chuck Hallenbeck chuckh at
Wed Aug 29 05:14:44 EDT 2007

Hash: SHA1

The sed utility has an option to edit a file "in place" so you don't
need the temp file. I think it is -i to do that.

On Tue, Aug 28, 2007 at 09:00:03PM +0100, Gaijin wrote:

> Chris Norman <chris,norman4&ntlworld,com> wrote:
> > I am writing a bash script. Part of the script involves deleting one
> > line of a file, which will be located anywhere in the file.
> cat <file> | grep -i "<text>" >temp-file>
> mv <temp-file> <file>
>     The above does an inverse grep, displaying everything BUT the line 
> of text you specify, and redirects the output to a temp file.  Then it 
> moves the newly created temp file onto the original file, overwriting 
> the original.  The sed equivalent would probably be:
> cat <file> | sed 's/<text to delete>//' > <output-file>
>     If you want to remove more than one line with matching text, add 
> the 'global' modifier to it:
> cat <file> | sed 's/<text to delete>//g' > <output-file>
>     Boning up on 'Regular Expressions' will help in this regard.  HTH,
>         Michael

> _______________________________________________
> Speakup mailing list
> Speakup at

- -- 
The Moon is Waning Gibbous (99% of Full)
My new web site location is at:
College, that fountain of knowledge, where everyone goes to drink.
Version: GnuPG v1.4.6 (GNU/Linux)


More information about the Speakup mailing list