用awk来显示一个特定的文件位置警告信息 [英] using awk to display warning message from a specific file location

查看:310
本文介绍了用awk来显示一个特定的文件位置警告信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用awk显示从文件中警告,如果有一个和一个没有错误的消息,如果有一个警告。警告将在字段2和第一行是一个标头。下面是我都试过了。谢谢:)

 的awk'!NR == 1 {下一;} $ 2 ={打印$ 2}'C:/用户/ cmccabe /桌面/ annovar / $ {ID} _name.txt

样品数据($ {ID} _name.txt)

 输入错误和警告ACCNO Genesymbol变异参考序列开始DESCR。编码DNA DESCR。蛋白质DESCR。 GeneSymbol编码DNA DESCR。 GeneSymbol蛋白DESCR。基因组参考编码参考参考蛋白影响的成绩单影响蛋白质限制网站创建限制网站已删除
NM_004004.5:c.244G>将(variantchecker)g的459位没有发现,发现的一种替代。

样本数据2

 输入错误和警告ACCNO Genesymbol变异参考序列开始DESCR。编码DNA DESCR。蛋白质DESCR。 GeneSymbol编码DNA DESCR。 GeneSymbol蛋白DESCR。基因组参考编码参考参考蛋白影响的成绩单影响蛋白质限制网站创建限制网站已删除
NM_004004.5:c.79G>将NM_004004.5 GJB2_v001 c.79G>将n.294G>将c.79G>将P(Val27Ile)GJB2_v001:c.79G>将GJB2_v001:。P(Val27Ile)NM_004004.5 NP_003995.2 NM_004004.5(GJB2_v001):c.79G>将NM_004004.5(GJB2_i001):p(Val27Ile)BCCI,BtsCI,的FokⅠHpyCH4III。


解决方案

不知道我理解你想要什么做的。这里是跳过该文件(头),在第一行的脚本,经过解析每一行并查找每行中的第二场。如果没有发现错误,它打印没有错误。

 的awk'NR大于1 {E = $ 2;打印发现错误:,$ 2} END {如果(!E)打印没有错误;}'< file_name.txt>

如果你想打印整个错误消息(一切都在第二行,除了第一个字段),你可以这样做:

 的awk'NR大于1 {$ 1 =; E = $ 2;打印发现错误:,$ 0} END {如果(!E)打印没有错误;}'< file_name.txt>

I am trying to use awk to display a warning from a file if there is one and a "no error" message if there is a no warning. The warning would be in field 2 and the first row is a header. Below is what I have tried. Thank you :).

awk 'NR==1{next;} $2!=""{print $2}' C:/Users/cmccabe/Desktop/annovar/${id}_name.txt

Sample Data (from ${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. 

Sample Data 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   

解决方案

Not sure I understand exactly what you want to do.. Here is a script that skips the first line in the file (the header), parses every line after and looks for the second field in each line. If no error is found, it prints "No error".

awk 'NR>1 {e=$2; print "Found error: ", $2} END{if (!e) print "No error";}' <file_name.txt>

If you want to print the whole error message (everything in the second line except the first field), you can do something like:

awk 'NR>1 {$1=""; e=$2; print "Found error: ", $0} END{if (!e) print "No error";}' <file_name.txt>

这篇关于用awk来显示一个特定的文件位置警告信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆