[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ale] sed
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
- Follow-Ups:
- [ale] sed
- From: jkinney at localnetsolutions.com (James P. Kinney III)
- References:
- [ale] sed
- From: terry at bitlinx.com (Terry Bailey)
- [ale] sed
- From: cfowler at outpostsentinel.com (cfowler)
- [ale] sed
- From: vindir at comcast.net (Jamey Owens)
- [ale] sed
- From: ozone at webgroup.org (David Tomaschik)