I have 200 output files, of which I need to compare one line. The exact line varies, but Total Energy = xyz always exists. Is there an easy way to copy that line from my output files in a new file? I'm using Ksh, by the way.


1 Answer 1


grep is the simplest command for this.

Assuming you have files in one folder then

grep 'Total Energy =' dir/* > results.txt

Without more information on the way your files are named / organized, I can't be more precise. Hopefully this will let you solve it

Other solutions might use sed or awk, but grep is probably the simplest


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .