Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/file/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Awk 如果条件不忽略文本文件中的行_Awk - Fatal编程技术网

Awk 如果条件不忽略文本文件中的行

Awk 如果条件不忽略文本文件中的行,awk,Awk,为什么下面的awk命令不忽略以ChrC和ChrM开头的列: awk '{if($1 != "ChrC" || $1 != 'ChrM') print $0}' TAIR10_GFF3_genes-fix1.rm_rubbish_rm_protein_rm_id_rm_index.gff | cut -f1 | sort | uniq Chr1 Chr2 Chr3 Chr4 Chr5 ChrC ChrM ##gff-version 3 提前谢谢,由于未提供样品,因此无法测试,请尝试在awk内更改

为什么下面的awk命令不忽略以
ChrC
ChrM
开头的列:

awk '{if($1 != "ChrC" || $1 != 'ChrM') print $0}' TAIR10_GFF3_genes-fix1.rm_rubbish_rm_protein_rm_id_rm_index.gff | cut -f1 | sort | uniq
Chr1
Chr2
Chr3
Chr4
Chr5
ChrC
ChrM
##gff-version 3

提前谢谢,

由于未提供样品,因此无法测试,请尝试在
awk
内更改您的条件。IMHO为什么要打印它,因为它是一个或条件,所以如果一个零件出现故障,那么它也将打印行(基于
1 | 0
-->
1
)的逻辑或条件,在
条件下不会发生

if($1 != "ChrC" && $1 != "ChrM")
尝试(使用


可能
print$1
会为您节省
cut

为什么对
ChrC
ChrM
使用不同的引号?另一个选项是
\r\n
行尾(如果那些
'
引号是打字错误)。可能是隐藏字符?请尝试!~/ChrC/as condition或appen
od
,并在更改为
&
后在此处发布输出。为什么它不与
|
一起工作?更改为
后工作?
我相信问题已更新,因为有示例now@user977828,我进一步解释了为什么你的尝试没有成功,请检查一下。
awk '{if($1 != "ChrC" || $1 != "ChrM") print $0}' TAIR10_GFF3_genes-fix1.rm_rubbish_rm_protein_rm_id_rm_index.gff | cut -f1 | sort | uniq