Assuming you mean {line1} .. {line3} literally, then
Code:
awk '(FNR==1) { if (files > 0) printf("\n");
printf("{line%d}", ++files) }
(FNR<=5) { printf(" %s %s %s %s", $1, $2, $5, $10) }
END { if (files > 0) printf("\n") }
' file1 file2 file3 > output-file
but if you only want the fields, then
Code:
awk '(FNR==1) { if (files++>0) SP="\n" }
(FNR<=5) { printf("%s%s %s %s %s", SP, $1, $2, $5, $10); SP=" " }
END { if (files > 0) printf("\n") }
' file1 file2 file3 > output-file
FNR restarts from one for each new input file. The
(FNR==1) rule is only applied to first line of each input file, and it starts the output for a new output line. (In the latter awk snippet, SP will be by default empty for the first line of the first file, but a newline for the first line of any other files.)
The
(FNR<=5) rule is applied to first five lines of each input file. It outputs the first, second, fifth and tenth fields of the input line, but without a newline. (The latter one prepends no separator for the first line of first input file, a newline for the first line of any other input files, and a space for the second to fifth input lines of all input files.)
Since the last output line does not get a newline, we add one in the
END rule, but only if there have been input lines.
Note that you can specify any number of files. If you don't specify any, then standard input is used (as the only file).