sed append text - not working
am 03.10.2007 15:57:52 von peter sands
Hi,
I have the folowing entry at the end of a file ( called goods):
logger
I need to change this to :
logger WAC
I have tried:
$ sed -s '/logger/a\WAC' goods
But that does not work
Any help please appreciated
thanks
Pete.
Re: sed append text - not working
am 03.10.2007 15:59:36 von Ed Morton
peter sands wrote:
> Hi,
> I have the folowing entry at the end of a file ( called goods):
> logger
>
> I need to change this to :
> logger WAC
>
>
>
> I have tried:
> $ sed -s '/logger/a\WAC' goods
>
> But that does not work
>
> Any help please appreciated
>
> thanks
> Pete.
>
sed 's/logger/& WAC/'
Ed.
Re: sed append text - not working
am 04.10.2007 21:13:13 von Michael Tosch
Ed Morton wrote:
> peter sands wrote:
>> Hi,
>> I have the folowing entry at the end of a file ( called goods):
>> logger
>>
>> I need to change this to :
>> logger WAC
>>
>>
>>
>> I have tried:
>> $ sed -s '/logger/a\WAC' goods
>>
>> But that does not work
>>
>> Any help please appreciated
>>
>> thanks
>> Pete.
>>
>
> sed 's/logger/& WAC/'
>
> Ed.
If you want to ensure the substitution only
takes place at the end of the file, and not
for any else occurrence of "logger":
sed '$s/logger/& WAC/'
The a operator works as advertised:
sed -s '/logger/a\
WAC' goods
(on two lines)
But it will append a line with "WAC".
--
Michael Tosch @ hp : com