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]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [Fedora Magazine]     [Fedora News]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Maintainers]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Legacy]     [Fedora Desktop]     [Fedora Fonts]     [ATA RAID]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [SSH]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Centos]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Tux]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Asterisk PBX]     [Fedora Sparc]     [Fedora Universal Network Connector]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux