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,249
  • 5
  • 64
  • 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
  • 131,515
  • 23
  • 189
  • 171
1
paste -sd\  infile

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

Dimitre Radoulov
  • 25,984
  • 4
  • 38
  • 44
0
awk '{printf $0" "}' your_file
jaypal singh
  • 71,025
  • 22
  • 98
  • 142
0

Perl solution:

perl -l40pe1 infile
choroba
  • 216,930
  • 22
  • 195
  • 267