我有类似的输出
#################################################################
# If you used AutoDock Vina in your work, please cite: #
# #
# O. Trott, A. J. Olson, #
# AutoDock Vina: improving the speed and accuracy of docking #
# with a new scoring function, efficient optimization and #
# multithreading, Journal of Computational Chemistry 31 (2010) #
# 455-461 #
# #
# DOI 10.1002/jcc.21334 #
# #
# Please see http://vina.scripps.edu for more information. #
#################################################################
Detected 4 CPUs
Reading input ... done.
Setting up the scoring function ... done.
Analyzing the binding site ... done.
Using random seed: -1786073016
Performing search ... done.
Refining results ... done.
mode | affinity | dist from best mode
| (kcal/mol) | rmsd l.b.| rmsd u.b.
-----+------------+----------+----------
1 -10.7 0.000 0.000
2 -10.4 0.460 1.612
3 -8.6 1.625 6.452
4 -8.1 1.515 5.404
5 -8.1 1.569 5.214
6 -7.9 1.616 6.148
7 -7.9 1.380 2.324
Writing output ... done.
但我只想要以下作为输出
-10.7
-10.4
-8.6
-8.1
-8.1
-7.9
-7.9
我正在尝试以下命令行
grep ' kcal/mol ' ./1/data01/lig2_noch.pdbqt.txt | awk '{print $2}' >>test1.txt
但没有成功,任何人都可以快速解决如何在这些文件中获得如上所述的2美元数字吗?
答案 0 :(得分:3)
测试第一列是否为数字,然后打印第二列。
awk '$1 ~ /^[0-9]+$/ {print $2}' ./1/data01/lig2_noch.pdbqt.txt >> test1.txt
答案 1 :(得分:0)
尝试:如果您显示的输出始终相同,则以下内容可能对您有帮助。
awk '/output ... done/{A=""} /^-----/{A=1;next} A{print $2}' Input_file
寻找sting输出...完成并将变量A的值设为NULL。然后再次寻找一条线从一条线开始-----然后将变量A的值变为1.然后提到A意味着检查A的值是否为空然后打印$ 2(第二个字段)这是根据您的要求)。在这里提到Input_file。
您也可以使用上面的内容,或者如果输出来自运行脚本,那么您可以尝试使用:
./your_already_running_script | awk '/output ... done/{A=""} /^-----/{A=1;next} A{print $2}'