Com seus requisitos, você precisa de algo como este oneliner com um arquivo de saída:
(echo -e "SCF DONE\n1.0\n15.0 0 0\n0 15.0 0\n0 0 15.0\nTi O\n1 2\nDirect"; awk '/Ti|O/ {print $2 " " $3 " " $4}' foobar) > output_file
e sem:
echo -e "SCF DONE\n1.0\n15.0 0 0\n0 15.0 0\n0 0 15.0\nTi O\n1 2\nDirect"; awk '/Ti|O/ {print $2 " " $3 " " $4}' foobar
Ou crie um script foo
com este conteúdo:
#!/bin/bash
echo "SCF DONE"
echo "1.0"
echo "15.0 0 0"
echo "0 15.0 0"
echo "0 0 15.0"
echo "Ti O"
echo "1 2"
echo "Direct"
awk '/Ti|O/ {print $2 " " $3 " " $4}' "$1"
Exemplo
Seu arquivo de entrada foobar
:
30
SCF Done
Ti 52.3941 48.0198 49.5622
Ti 49.4797 49.061 50.7034
Ti 46.7489 51.0193 48.6784
Ti 49.2209 52.9008 48.3155
Ti 49.7834 46.7277 48.4888
Ti 52.6251 47.6201 52.5869
Ti 50.3918 52.7865 51.1559
Ti 47.6514 51.5936 51.7062
Ti 52.6228 50.7423 51.3614
Ti 49.082 49.5289 47.4413
O 50.6524 50.7772 50.9831
O 49.7273 51.3294 47.4124
O 46.2227 51.3762 50.4682
O 51.1925 48.1984 51.2227
O 53.004 49.4764 52.6582
O 53.4681 47.2549 50.9251
O 49.01 52.6769 52.4943
O 48.6199 52.3487 50.1333
O 49.0692 47.6549 47.0357
O 51.6141 46.4856 48.7282
O 48.8938 47.2992 50.0114
O 48.317 49.9127 49.2982
O 52.4147 46.508 53.9714
O 50.5076 53.6822 49.4331
O 53.0515 49.783 49.8138
O 50.5672 48.7353 48.7478
O 47.3746 52.6644 47.9578
O 52.2093 52.5518 51.6378
O 47.2328 50.0047 47.1441
O 48.2864 49.8647 51.9765
A saída de ./foo foobar
:
SCF DONE
1.0
15.0 0 0
0 15.0 0
0 0 15.0
Ti O
1 2
Direct
52.3941 48.0198 49.5622
49.4797 49.061 50.7034
46.7489 51.0193 48.6784
49.2209 52.9008 48.3155
49.7834 46.7277 48.4888
52.6251 47.6201 52.5869
50.3918 52.7865 51.1559
47.6514 51.5936 51.7062
52.6228 50.7423 51.3614
49.082 49.5289 47.4413
50.6524 50.7772 50.9831
49.7273 51.3294 47.4124
46.2227 51.3762 50.4682
51.1925 48.1984 51.2227
53.004 49.4764 52.6582
53.4681 47.2549 50.9251
49.01 52.6769 52.4943
48.6199 52.3487 50.1333
49.0692 47.6549 47.0357
51.6141 46.4856 48.7282
48.8938 47.2992 50.0114
48.317 49.9127 49.2982
52.4147 46.508 53.9714
50.5076 53.6822 49.4331
53.0515 49.783 49.8138
50.5672 48.7353 48.7478
47.3746 52.6644 47.9578
52.2093 52.5518 51.6378
47.2328 50.0047 47.1441
48.2864 49.8647 51.9765
Ou com um redirecionamento em um arquivo de saída:
./foo foobar > output_file