0

I have file like this:

1
2
3
4

How to get result like that by awk or similar:

1 2 3 4
lucapette
  • 20,564
  • 6
  • 65
  • 59
  • For a highly rated sed solution (and an additional awk solution): http://stackoverflow.com/questions/1251999/sed-how-can-i-replace-a-newline-n – Christopher Dec 02 '11 at 22:14

4 Answers4

4
echo $(cat file)

if the file is short.

awk '{printf("%s ",$0)}' <file

if you want awk or similar.

Michael Krelin - hacker
  • 138,757
  • 24
  • 193
  • 173
1
paste -sd\  infile

Note that the above command contains two white space characters (an escaped and a plain one).

Dimitre Radoulov
  • 27,252
  • 4
  • 40
  • 48
0
awk '{printf $0" "}' your_file
jaypal singh
  • 74,723
  • 23
  • 102
  • 147
0

Perl solution:

perl -l40pe1 infile
choroba
  • 231,213
  • 25
  • 204
  • 289