I have the file:
key value
blah blah
blah blah
blahblah
man1 boy1
blah blah
man1 boy2
man1 boy1
I do this to remove duplicate lines:
awk '/man1/ { print $1,$2} ' file | awk '!x[$0]++'
and the command take the first line and ignore other lines
man1 boy1
man1 boy2
but I want to ignore all lines except the last line:
man1 boy2
man1 boy1
as ramesh said I want something like:
cat filename
blah blah
blah blah
blahblah
man1 boy1
blah blah
man1 boy2
man1 boy1
man1 boy2
man1 boy3
man1 boy4
man1 boy2
the desired output
man1 boy1
man1 boy3
man1 boy4
man1 boy2
Best Answer
you can do this using this shell script:
Output:
Source