paste
does exactly what you want.
DESCRIPTION
Write lines consisting of the sequentially corresponding lines from
each FILE, separated by TABs, to standard output. With no FILE, or
when FILE is -, read standard input.
Mandatory arguments to long options are mandatory for short options
too.
-d, --delimiters=LIST
reuse characters from LIST instead of TABs
In your case
paste -d " " a b c
will do the trick. If you need the output in a file, redirect >output
the output.
To access the
n-th
line of a file, use
sed
. For convenience wrap it up in a Bash function (
pl
is supposed to mean Print Line)
function pl {
sed -n "$1p" $2
}
Calling for example pl 5 a
will print the fifth line of file a
. To store it in a variable
fifth=$(pl 5 a)
or combine both tasks
paste a b c | pl 5 -
to print the fifth line of the concatenated file.
To get a file into an array, use mapfile
, from this answer:
mapfile -t myArray < output.txt