Re: compare files

"[email protected] [sed-users]" <[email protected]> 09 Jan 2017 12:50:25 -0800
Newsgroups gmane.editors.sed.user
Message-ID <[email protected]>
Yet another way where we can instead of lugging around the files A & B into the pattern space till the end, print the mapped lines of fileB and clear em from the P.S. soon as they get mapped looking at fileA. 
 Also note that the [^\n] regex is not Posix and so is avoided.
 

 usage:  sed -f   run.sed  fileB.txt   fileA.txt
 

 

 :read

    $bend
    N
 bread
 :end
 h
 y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/
 s/^//;treset
 :reset
 s/^\([^,]*,\)\{3\}[  ]*'\([^']*\)'.*\n\(.*\n\)\{0,1\}\2;\([12]\);.*/\4/;tmap
 s/.*/0/
 :map
 x;H;g
 s/^\(.\)\n\(\([^,]*,\)\{3\}[  ]*\)'\([^']*\)'/\2'\1'/
 /^(/!d
 P;D
 #################################################

 

 





[Non-text portions of this message have been removed]