Here is my 1.file
id
a1
a2
a3
a4
Here is my 2.file
DW 1 2 3 4
KD 2 3 4 5
LBJ 4 4 4 4
I want to get my final file
id a1 a2 a3 a4
DW 1 2 3 4
KD 2 3 4 5
LBJ 4 4 4 4
And I try to
cat 1.file |tr "\n" "\t"|sed -e 's/,$/\n/'
and then
cat 1.file 2.file >> fina.file
but I want to get the awk
way
tr
to convert newlines to some other character and then pipe the result to a different text processing tool because removing all of the newlines turns your text into something that can't reliably be read by any text processing tool as it's now undefined behavior (all text processing tools are only guaranteed to work with valid text file input and a valid text file MUST have a newline at the end. Also see porkmail.org/era/unix/award -cat file | cmd
can always be written as eithercmd file
orcmd < file
for any commandcmd
.