我正在尝试使用awk来显示文件中的警告(如果有)并且没有错误"消息,如果没有警告。警告将在字段2中,第一行是标题。以下是我的尝试。谢谢你:)。
awk 'NR==1{next;} $2!=""{print $2}' C:/Users/cmccabe/Desktop/annovar/${id}_name.txt
示例数据(来自$ {id} _name.txt)
Input Errors and warnings AccNo Genesymbol Variant Reference Sequence Start Descr. Coding DNA Descr. Protein Descr. GeneSymbol Coding DNA Descr. GeneSymbol Protein Descr. Genomic Reference Coding Reference Protein Reference Affected Transcripts Affected Proteins Restriction Sites Created Restriction Sites Deleted
NM_004004.5:c.244G>A (variantchecker): G not found at position 459, found A instead.
样本数据2
Input Errors and warnings AccNo Genesymbol Variant Reference Sequence Start Descr. Coding DNA Descr. Protein Descr. GeneSymbol Coding DNA Descr. GeneSymbol Protein Descr. Genomic Reference Coding Reference Protein Reference Affected Transcripts Affected Proteins Restriction Sites Created Restriction Sites Deleted
NM_004004.5:c.79G>A NM_004004.5 GJB2_v001 c.79G>A n.294G>A c.79G>A p.(Val27Ile) GJB2_v001:c.79G>A GJB2_v001:p.(Val27Ile) NM_004004.5 NP_003995.2 NM_004004.5(GJB2_v001):c.79G>A NM_004004.5(GJB2_i001):p.(Val27Ile) BccI,BtsCI,FokI HpyCH4III
答案 0 :(得分:0)
我不确定我到底想要做什么。这是一个跳过文件中第一行(标题)的脚本,解析后面的每一行并查找每行中的第二个字段。如果未找到错误,则显示“无错误”。
awk 'NR>1 {e=$2; print "Found error: ", $2} END{if (!e) print "No error";}' <file_name.txt>
如果要打印整个错误消息(除第一个字段外的第二行中的所有内容),您可以执行以下操作:
awk 'NR>1 {$1=""; e=$2; print "Found error: ", $0} END{if (!e) print "No error";}' <file_name.txt>