how to convert rows into column using awk?
awk
Solution
Try this:
awk '{printf("%s ", $0)}'
using a pipe:
whatever_your_command | awk '{printf("%s ", $0)}'
The advantage of using `printf()` is that it gives you complete control over the output format/spacing/etc of your data.
--
Testing
822
526006
1343315205
1.4.2
32
0.000000
13.048815
data in file `data.txt`:
awk '{printf("%s ", $0)}' data.txt
yields:
822 526006 1343315205 1.4.2 32 0.000000 13.048815
Problem
I have an input contains of 36 lines like this: ``` 822 526006 1343315205 1.4.2 32 0.000000 13.048815 ... 0 0 0 ``` That is the output from memcache stats command. So it is not from a file. How can I convert those lines into a columns of a single row. I don't want to use temp file. Thanks,