Re: sed, awk, or something...help meeeeeeeeeee

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

 



2009/9/28 Joerg Bergmann <email@xxxxxxxxxxxx>:
> Am 28.09.2009 21:07, schrieb Sharpe, Sam J:
>> You specified that BB was to be /replaced/ with BBBB1, so you will
>> need to do this:
>>
>> [sam@samlap Desktop]$ sed -e '/BB/R file2' -e '/BB/d' file1

>
> This code may fail in case file 2 contains a line with BB only,
> in that case the replacement will be removed too.

Always best to check your statements before you criticise my code.

Because of the way sed works, the second -e operates on the original
line and not the replaced one, you are wrong and I am (still) correct.

[sam@samlap Desktop]$ cat file1
AA
BB
CC
DD

AA
BB
CC
DD
[sam@samlap Desktop]$ cat file2
BBBB1
BB
BBBB3

[sam@samlap Desktop]$ sed -e '/BB/R file2' -e '/BB/d' file1
AA
BBBB1
CC
DD

AA
BB
CC
DD

If you wanted to be totally correct, you should actually do:

$ sed -e '/^BB$/R file2' -e '/^BB$/d' file1

Laterz,

Sam

-- 
fedora-list mailing list
fedora-list@xxxxxxxxxx
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines

[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux