sed, awk, or something...help meeeeeeeeeee

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

 



Hi All,

I don't know if I should use sed for what I'm about to ask, but it seems
like a good idea.  If awk is better, or something else entirely, that's
fine too.

I have two files.  File "1" looks like this:

AA
BB
CC
DD

AA
BB
CC
DD

File "2" looks like this:

BBBB1
BBBB2
BBBB3

So, "BB" in file "1" always occurs in the same spot (i.e. between lines
AA and CC).  Knowing that, how do I replace the first occurrence of "BB"
in file "1" with "BBBB1" from file 2, the second occurrence of "BB" in
file "1" with "BBBB2" from file 2, and so on?

I think a bash 'for' or 'while' loop may be useful here, too.  But, it's
the sed/awk/whatever bits I don't know how to do.  I've read some of the
man/info page, looked up sed help on the net, etc.  I'm still not sure
how to do the above with sed.

Thanks in advance!

Regards,

Ranbir

-- 
Kanwar Ranbir Sandhu
Linux 2.6.27.30-170.2.82.fc10.x86_64 x86_64 GNU/Linux 
13:29:18 up 9 days, 3:04, 3 users, load average: 1.13, 0.37, 0.18 


-- 
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