我有一个文本文件,我想删除冒号前的字符串。
TXT文件:
jhu-usc.edu_.450.1.lvl-3.TA-LK-A4NW-01A-11D-A34E-05.txt:05556808 0.916496542
jhu-usc.edu_.450.1.lvl-3.TA-LK-A4NW-01A-11D-A34E-05.txt:08883127 0.891518088
jhu-usc.edu_.450.1.lvl-3.TA-LK-A4NW-01A-11D-A34E-05.txt:10537079 0.827900035
jhu-usc.edu_.450.1.lvl-3.TA-LK-A4NW-01A-11D-A34E-05.txt:12497728 0.90517593
jhu-usc.edu_.450.1.lvl-3.TA-LK-A4NW-01A-11D-A34E-05.txt:13195463 NA
jhu-usc.edu_.450.1.lvl-3.TA-LK-A4NW-01A-11D-A34E-05.txt:22240159 0.809459655
jhu-usc.edu_.450.1.lvl-3.TA-LK-A4NW-01A-11D-A34E-05.txt:27050343 NA
jhu-usc.edu_.450.1.lvl-3.TA-LK-A4NY-01A-11D-A34E-05.txt:05556808 0.816581048
jhu-usc.edu_.450.1.lvl-3.TA-LK-A4NY-01A-11D-A34E-05.txt:08883127 0.864387435
jhu-usc.edu_.450.1.lvl-3.TA-LK-A4NY-01A-11D-A34E-05.txt:10537079 0.565236625
期望输出:
5556808 0.916496542
8883127 0.891518088
10537079 0.827900035
12497728 0.90517593
13195463 NA
22240159 0.809459655
27050343 NA
5556808 0.816581048
8883127 0.864387435
10537079 0.565236625
我试过但没成功。
最佳答案
sed
sed 's/^[^:]*://' file.txt
grep
grep -o '[^:]*$' file.txt
awk
awk -F: '{print $2}' file.txt
关于regex - linux通过sed剪切了reg表达模式,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/39221453/