I have columns of data arriving from standard output (in my case a call to mysql), and I would like to append at each loop the column in a file. How can I do?
Standard output:
a1
a2
....
an
Saving in a file called table.dat:
table.dat:
a1
a2
....
an
Then another output is produced:
Further standard output:
b1
b2
....
bn
Appending to table.dat:
table.dat:
a1 b1
a2 b2
.... ....
an bn
...and so on. I can use paste, but I need three steps:
line producing standard output > tmpfile;
paste prevfile tmpfile > table
mv table prevfile;
Is there a faster way, maybe by using awk?
This solution: Add a new column to the file produces an empty table.