我有这种模式的输出:grep的模式,而忽略其他
Auxiliary excitation energy for root 3: (variable value)
这似乎时间在输出结果的数字,但我只希望到grep最后一个。 我在bash初学者,所以我不明白的“尾巴” fonction尚未...
这里是我写的:
for nn in 0.00000001 0.4 1.0; do
for w in 0.0 0.001 0.01 0.025 0.05 0.075 0.1 0.125 0.15 0.175 0.2 0.225 0.25 0.275 0.3 0.325 0.35 0.375 0.4 0.425 0.45 0.475 0.5; do
a=`grep ' Auxiliary excitation energy for root 3: ' $nn"_"$w.out`
echo $w" "${a:47:16} >> data_$nn.dat
done
done
随着$ NN和$ W参数。
但是这个grep我只有第一个模式。如何才能得到最后一个?
数据例如:
line 1 Auxiliary excitation energy for root 3: 0.75588889
line 2 Auxiliary excitation energy for root 3: 0.74981555
line 3 Auxiliary excitation energy for root 3: 0.74891111
line 4 Auxiliary excitation energy for root 3: 0.86745155
我的命令grep的1号线,我想给grep其中有我的模式的最后一行:这里有我的例子线4。
对不起,你不清楚你需要什么。你能否用多行重新提供提供样本数据的问题,并准确指定要捕获的内容? – theMarceloR 2014-09-02 15:51:43
@theMarceloR:我添加一个数据的例子,我希望这会有所帮助。 – 2014-09-03 11:00:25