Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting



View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
    #2  
Old 10-06-2005
Ygor's Avatar
Ygor Ygor is offline Forum Staff  
Moderator
 
Join Date: Oct 2003
Location: 54.23, -4.53
Posts: 1,792
Thanks: 1
Thanked 101 Times in 91 Posts
You can't use sed because its processing is line-based. You can use awk if you unset the record separator, like this...
Code:
awk ' BEGIN { RS="" }
      FILENAME==ARGV[1] { s=$0 }
      FILENAME==ARGV[2] { r=$0 }
      FILENAME==ARGV[3] { sub(s,r) ; print }
    ' exfile2 exfile3 exfile1 > exfile4

..which gives...
Code:
asdasdasdasd
asdasdasdasd
jkl
mno
pqr
sdasdasdasda
asdasdasdada