Combine columns from several files into one
awk 'FNR==1 {print $2}' file*
This prints the second column ($2
) of the first line (FNR==1
) for every file whose filename starts with file
.
An alternative is to print the first line and then immediately skip to the next file (nextfile
is a mawk
and GNU awk
-specific keyword):
awk '{print $2; nextfile}' file*