Kumar
Kumar

Reputation: 717

How to arrange elements that is there in a single column to multiple using sed or awk?

My File content:

Apple
Banana
orange
Donkey
Elephant
Fox
Good

I am trying to arrange elements that is there in a single column(as shown above) into two columns as shown below:

Expected output:

Apple          Banana
Orange         Donkey
Elephant       Fox
Good

Is there any way in Sed or awk to achieve this?

Upvotes: 1

Views: 42

Answers (1)

nu11p01n73R
nu11p01n73R

Reputation: 26667

How about something like

$ awk 'ORS=(NR%2)?" ":"\n"' input
Apple Banana
orange Donkey
Elephant Fox
Good 

OR

$ awk 'ORS=(NR%2)?FS:RS' input | column -t
Apple     Banana
orange    Donkey
Elephant  Fox
Good

Upvotes: 2

Related Questions