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

Re: sed/awk/fmt question hijacked from Re: Program for quoting text like in email?



In <[🔎] 4A2DC587.60608@gmail.com>, Tony Baldwin wrote:
>Why is it that with sed, stuff like
>sed -e /searchterm/d
>I have to do
>sed -e /searchterm/d infile > outfile,
>and can't just do sed -e /searchterm/d file, without having to generate
>another file?

Traditional sed is very simple.  It doesn't "know" how to "save" the data it 
is going to read before overwriting it or truncate the file after it is done 
writing.  It just reads some bytes and writes some other bytes.  Because of 
this, operating on the same set of bytes for both reading and writing could 
give disastrous results.

GNU sed is much more featureful.  It has the '-i' option to do an "in place" 
sed.
-- 
Boyd Stephen Smith Jr.           	 ,= ,-_-. =.
bss@iguanasuicide.net            	((_/)o o(\_))
ICQ: 514984 YM/AIM: DaTwinkDaddy 	 `-'(. .)`-'
http://iguanasuicide.net/        	     \_/

Attachment: signature.asc
Description: This is a digitally signed message part.


Reply to: