my input file has blocks like
[abc]
para1=123
para2=456
para3=111
[pqr]
para1=333
para2=765
para3=1345
[xyz]
para1=888
para2=236
para3=964
[pqr]
para1=tyu
para2=ghj
para3=ghjk
[xyz]
para1=qwe
para2=asd
para3=zxc
Now I need to delete the block which is duplicate using sed or awk. Have to delete the block which we get first from the top of the file. Ex: in above case, we have get the output like
[abc]
para1=123
para2=456
para3=111
[pqr]
para1=tyu
para2=ghj
para3=ghjk
[xyz]
para1=qwe
para2=asd
para3=zxc
This keeps the last instance of each block not the first
Slight problem with this method is that as the field separator is a newline the lines have to have the same amount of whitespace after the text as it is counted as the field.
Otherwise should work perfectly :)
This also works :)
.
I do get this from using
awk
(not sure if you did forget theabc
block)