Now, how to extract data from multiple output files, say out1.log, out2.log, out3.log in a single step?
Any suggestions on how to combine the second and third awk commands to a single command [as the commands output 'line 3' and 'line 13' respectively, after the common 'string'].
The code works well, and it writes out out1a.txt, out2a.txt, out2a.txt. If I need only one output (for the first awk command, out1a.txt) with all the data extracted sequentially into it from out1.log, out2.log and out3.log, what do I need to do? When I replace '${i}' with out1a.txt, only data from out1.log gets extracted. Thank You!:rolleyes:
Thank you Chubler. The code worked great. I appreciate your time and help!!!
However, if I have to repeat the same for second awk (I have made a separate
script), it doesn't work.
rm -f outb.txt
for i in out1 out2 out3; do
echo "===== Processing file $i =====" >> outb.txt
awk '/ test-string/{m=1;c=0}m&&++c==3{print $2 " " $3 " " $4}m&&c==13{print $2 " " $3 " " $4 ;m=0}' $i.log >> outb.txt
echo "===== Finished with file $i =====" >> outb.txt
done