[ale] sed

Geoffrey lists at serioustechnology.com
Fri May 18 09:02:54 EDT 2007


David Tomaschik wrote:
> Jamey Owens wrote:
>> One note of caution.  It can be pretty dangerous to try and use the same 
>> file for input and output.  Lots of shells will leave you with a totally 
>> empty file using the previous sed command with input & output being equal.
>>
>>   
> Are there any shells capable of handling that structure in the way one
> would expect?  (i.e., acting on the single file without destroying or
> requiring a temporary file to be moved around)

For those of us who are old enough to have used 'ed' prior to 'vi' you 
can do what you want with 'ed' and a 'here document' as follows:

ed inputfile << ENDHERE
1,$ s/abc/xyz/g
w
q
ENDHERE

-- 
Until later, Geoffrey

Those who would give up essential Liberty, to purchase a little
temporary Safety, deserve neither Liberty nor Safety.
  - Benjamin Franklin



More information about the Ale mailing list