Reputation: 289
I have a list of *.mto file containing my simulation result. They have the format as:
vtpr vtpf temper alter#
5.849e-01 3.034e-01 2.500e+01 1
I want to get the value of vtpr and vtpf in each input files, then save them to a result file. Somebody suggest me use sed but i have no idea how can it works with multiple files. I use this code to print the 2nd line but in the result file, there's only the value of the final input files, not all the value because it's overwrited each time. can u give me some suggest ? thanks for help.
find . -name '*.mt0' -exec sed -n '2w result.txt' "{}
"\;
Upvotes: 0
Views: 56
Reputation: 63698
Use cut
with correct delimiter(default is TAB)
find . -name '*.mt0' -type f -exec sed -n '2{p;q}' {} \; | cut -f2 -d' ' > output
Upvotes: 1