sed: uniq -u
1
1 7.19 Remove All Duplicated Lines
1 ================================
1
1 This script prints only unique lines, like 'uniq -u'.
1
1 #!/usr/bin/sed -f
1
1 # Search for a duplicate line --- until that, print what you find.
1 $b
1 N
1 /^\(.*\)\n\1$/ ! {
1 P
1 D
1 }
1
1 :c
1 # Got two equal lines in pattern space. At the
1 # end of the file we simply exit
1 $d
1
1 # Else, we keep reading lines with N until we
1 # find a different one
1 s/.*\n//
1 N
1 /^\(.*\)\n\1$/ {
1 bc
1 }
1
1 # Remove the last instance of the duplicate line
1 # and go back to the top
1 D
1