| Newsgroups |
gmane.editors.sed.user |
| Message-ID |
<[email protected]> |
Since this is a "sed" editor forum, a sed-based solution is presented:
Note that you need to place a dummy line of all stars ******
as the last line of the 2015.txt file in order to distinguish the
ending of 2015.txt & start of 2016.txt.
Assuming the GNU "sed" being used, for two main reasons, enough
memory for hold space & [^\n] regular expression for a nonnewline to
be matched.
Ordering of arguments is: 1st arg = 2015.txt 2nd arg = 2016.txt
sed -e '
1{
# read in the 2015.txt file
:f2015
$!N
/\n\*\**$/!bf2015
s///;h;d
# now the 2015.txt file is in the hold space
}
G
# same
/^\([^\n]*\)\n\(.*\n\)\1\n/{
s/^\([^\n]*\)\n\(.*\n\)\1\n/\2/;h;$bend;d
}
/^\([^\n]*\)\n.*\n\1$/{
s/^\([^\n]*\)\n\(.*\)\n\1$/\2/;h;$bend;d
}
/^\([^\n]*\)\n\1\n/{
s/^\([^\n]*\)\n\1\n//;h;$bend;d
}
/^\([^\n]*\)\n\1$/{
s/^\([^\n]*\)\n\1$//;h;$bend;d
}
# modified
/^\("[1-9][0-9]*"\);[^\n]*\n.*\n\1;/{
s/^\(\("[1-9][0-9]*"\);[^\n]*\n.*\n\)\2;[^\n]*\n/\1/;tmodified
s/^\(\("[1-9][0-9]*"\);[^\n]*\n.*\n\)\2;[^\n]*$/\1/
:modified
h;s/\n.*//;s/./&/w /tmp/modify_from_2015.log
g;s/^[^\n]*\n//;h;$bend;d
}
/^\("[1-9][0-9]*"\);[^\n]*\n\1;/{
s/^\(\("[1-9][0-9]*"\);[^\n]*\n\)\2;[^\n]*\n/\1/;tmodified
s/^\(\("[1-9][0-9]*"\);[^\n]*\n\)\2;[^\n]*$/\1/;bmodified
}
# new line
s/\n.*//;s/./&/w /tmp/new_in_2016.log
$!d
:end
g
' 2015.txt 2016.txt > /tmp/remove_from_2015.log
HTH
-Rakesh
[Non-text portions of this message have been removed]