Tejesh Chilla
Tejesh Chilla

Reputation: 113

how to compare two columns in a single file in unix

My req is i need to get the output if the two columns are not equal below is my code.

The output is as below here my req is for example the first shouldnt be printed as both are equal the second should be printed as both are not equal.

cat testingfull.txt|sed -n '/"Exp_CDL_BOOKINGS_F"/,/TABLEATTRIBUTE NAME/p'|grep EXPRESSION | awk -F"\"" '{print $8,"=",$12}'

BOOK_DATE_KEY=BOOK_DATE_KEY
Lkp_BOOKINGS_FACT_KEY=iif( not  isnull(i_BOOKINGS_FACT_KEY) and isnull(iif(BOOK_DATE_KEY<>Lkp_BOOK_DATE_KEY, NULL)),null,i_BOOKINGS_FACT_KEY)
BOOKINGS_FACT_KEY=Lkp_BOOKINGS_FACT_KEY

Upvotes: 9

Views: 16780

Answers (2)

svante
svante

Reputation: 1385

This should work for you (trail this to your current line) :

... | awk -F'=' '$1!=$2'

Upvotes: 3

anubhava
anubhava

Reputation: 785156

Compare columns in your awk command:

awk -F'"' '$8!=$12 {print $8,"=",$12}'

Upvotes: 14

Related Questions