我是bash的新手,我需要从文件中提取数据。我这样写了
awk '/Iteration/''{print $3$4}''/TOTEN/''{print $5}''/energy without entropy/'
'{print $5 }''/energy without entropy/''{print $8 }' "OUTCAR.txt" > test.txt
输出就像这样
1(1)
-298.23864042
-298.23333028
-298.23731288
1(2)
-1924.01607328
-1924.02845253
-1924.01916810
但我希望每4个结果在不同的列中但是单行。我尝试了awk -F'“”'但它删除了所有结果,只留下空行 编辑:我想要这样的东西
title1 title2 title3 title4
1(1) -298.23864042 -298.23333028 -298.23731288
1(2) -1924.01607328 -1924.02845253 -1924.01916810
答案 0 :(得分:2)
awk '/Iteration/{printf "%s%s\t", $3, $4}
/TOTEN/{printf "%s\t", $5}
/energy without entropy/{printf "%s\t%s\n", $5, $8 }' OUTCAR.txt