我有许多文件(250-20000 之间),每个文件都包含两列和头文件。 我想从这些文件中提取第二列并将它们全部粘贴到一个文件中,以便我可以对其进行分析。
#Frame Dih_00000
1 -92.6371
2 -97.9913
3 -91.1572
4 -89.9374
5 -91.8934
6 -93.1060
7 -93.4912
文件看起来像这样。 请您帮助我如何使用 awk 或 python 脚本来完成此操作。
最佳答案
awk '{print $2}' dihed_*.dat > file.new
或者只使用cut
命令
cut -d" " -f2 dihed_*.dat > file.new
编辑
不知道它是否优雅,但它满足您的要求。
tail -q -n +2 dihed_*.dat | awk '{print $2}' > file.new
还有
tail -q -n +2 dihed_*.dat | cut -d" " -f2 > file.new
关于python - 从多个文件中提取一列并将其粘贴到一个文件中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24864572/