target_id tpm tpm tpm tpm tpm tpm tpm tpm tpm tpm tpm
PB.1.1|1:6643-11779(-)|transcript/55100 9207.33 13266.4 15244.3 2844.27 2708.52 2731.91 3193.83 2675.78 3413.74 4001. 37 3332.62
PB.2.1|1:11961-16372(+)|transcript/24543 14.2016 27.8457 29.6335 7.14533 7.34512 7.64953 8.71118 6.87958 7.228 98 6.3592 5.94422
PB.2.2|1:11961-16373(+)|transcript/30117 2.70221 2.74091 2.81943 3.99669 2.69497 2.82466 3.01701 2.62054 2.958 49 2.48024 2.44429
PB.2.3|1:11962-16374(+)|transcript/35082 1.21596 1.76974 2.24733 1.76356 2.05692 1.7765 1.65524 1.44116 1.970 26 2.16288 1.50391
PB.3.1|1:27833-34327(+)|transcript/44399 71.0007 131.61 145.062 24.9771 23.0295 24.9615 26.8033 20.4961 25.36 6 26.6337 21.9282
PB.4.1|1:39316-44582(-)|transcript/24897 26.5017 37.3793 43.4624 11.1199 8.80527 8.18072 12.612 10.0202 12.24 37 8.06654 7.04677
PB.4.2|1:39317-44595(-)|transcript/39771 9.23018 9.89149 7.58203 10.1779 8.67577 7.9611 8.5775 9.83895 7.638 42 6.40913 6.58653
PB.4.3|1:39318-43423(-)|transcript/29985 20.8149 20.6359 14.5622 3.89209 3.92182 3.4396 4.53606 2.6505 3.979 53 2.92956 2.63565
PB.5.1|1:44841-49854(-)|transcript/24019 36.302 19.7211 18.3107 71.1272 70.6337 65.391 62.6371 61.8226 67.62 43 55.2076 57.7828
所以我想删除第一个|
到第一个小数之后的数字。例如我想要输出:
PB.1.1| 9207.33 13266.4 15244.3 2844.27 2708.52 2731.91 3193.83 2675.78 3413.74 4001. 37 3332.62.
我尝试过使用该cut
命令,但只能剪切第一个分隔符之后的所有内容,有任何指针吗?
答案1
一个简单的解决方案是使用 awk 并指定|
为字段分隔符。
awk 'BEGIN {FS="|"} ; {print $1"|"$3}'
这将打印第一个和第三个字段。所以对于你的例子我得到:
PB.1.1|transcript/55100 9207.33 13266.4 15244.3 2844.27 2708.52 2731.91 3193.83 2675.78 3413.74 4001. 37 3332.62
PB.2.1|transcript/24543 14.2016 27.8457 29.6335 7.14533 7.34512 7.64953 8.71118 6.87958 7.228 98 6.3592 5.94422
PB.2.2|transcript/30117 2.70221 2.74091 2.81943 3.99669 2.69497 2.82466 3.01701 2.62054 2.958 49 2.48024 2.44429
PB.2.3|transcript/35082 1.21596 1.76974 2.24733 1.76356 2.05692 1.7765 1.65524 1.44116 1.970 26 2.16288 1.50391
PB.3.1|transcript/44399 71.0007 131.61 145.062 24.9771 23.0295 24.9615 26.8033 20.4961 25.36 6 26.6337 21.9282
PB.4.1|transcript/24897 26.5017 37.3793 43.4624 11.1199 8.80527 8.18072 12.612 10.0202 12.24 37 8.06654 7.04677
PB.4.2|transcript/39771 9.23018 9.89149 7.58203 10.1779 8.67577 7.9611 8.5775 9.83895 7.638 42 6.40913 6.58653
PB.4.3|transcript/29985 20.8149 20.6359 14.5622 3.89209 3.92182 3.4396 4.53606 2.6505 3.979 53 2.92956 2.63565
PB.5.1|transcript/24019 36.302 19.7211 18.3107 71.1272 70.6337 65.391 62.6371 61.8226 67.62 43 55.2076 57.7828
答案2
sed -e 's/|.\{33\}//w test2.txt' test.txt
这工作正常,不管怎样谢谢大家。
答案3
使用以下命令进行测试并且工作正常
命令
sed 's/|.*|transcript\/[0-9]\{5\} /| /g' filename