Delete lines containing repeated text

awksedtext processing

I have a file containing two paths on each line. I want to remove the lines containing the same path twice.

I work on Linux and Solaris. I would like a one-liner in sed or awk or perl.

Example input file:

     /usr/lib/libgmp.so.3.3.3 /usr/lib/libgmp.so.3.3.3
     /usr/lib/libxslt.so.1.1.17 /usr/lib/libxslt.so.1.1.17
     /usr/lib/sse2/libgmp.so.3.3.3 /usr/lib/sse2/libgmp.so.3.3.3
     /usr/local/swp-tomcat-6.0/lib/commons-logging-1.1.1.jar /usr/local/swp-tomcat-6.0/lib/commons-logging-1.1.1.jar
     /usr/share/doc/libXrandr-1.1.1 /usr/share/doc/libXrandr-1.1.1
     /usr/share/doc/libxslt-1.1.17 /usr/share/doc/libxslt-1.1.17
     /etc/3.3.3.255 /etc/172.17.211.255
     /etc/1.1.1.255 /etc/172.17.213.255

Expected output:

     /etc/3.3.3.255 /etc/172.17.211.255
     /etc/1.1.1.255 /etc/172.17.213.255

Best Answer

awk '{ if ($1 != $2 ) print $1" "$2; }' file

Just replace file for the appropriate file.

Or as @manatwork mentioned in the comments and simpler

awk '$1!=$2' file
Related Question