newzad
newzad

Reputation: 706

single line from multidimensional array, using awk

I have a file which contains:

x1 x2 x3 x4
x5 x6 x7 x8
x9

Which I want:

x1
x2 
x3
 .
 .

How you do that using awk or in another ways?

Upvotes: 1

Views: 74

Answers (1)

Chris Seymour
Chris Seymour

Reputation: 85865

With awk:

$ awk '1' RS=' ' ORS='\n' file
x1
x2
x3
x4
x5
x6
x7
x8
x9

However personally I would do:

$ xargs -n1 < file
x1
x2
x3
x4
x5
x6
x7
x8
x9

or:

$ grep -o '\S*' file
x1
x2
x3
x4
x5
x6
x7
x8
x9

Upvotes: 4

Related Questions