bash 如何在unix中比较单个文件中的两列

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19377716/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 08:18:32  来源:igfitidea点击:

how to compare two columns in a single file in unix

bashunix

提问by Tejesh Chilla

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 ,"=",}'

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

回答by anubhava

Compare columns in your awk command:

比较 awk 命令中的列:

awk -F'"' '!= {print ,"=",}'

回答by svante

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

这应该对您有用(将其跟踪到您当前的行):

... | awk -F'=' '!='