0

I have the output of a command that can list between 8 and 800 hosts.

I am trying to figure out how to break this into 3 or 4 columns.

Right now I am using "fmt | column" but the output is not as neat as I wish.

  • 1
    so what is your example of "neat"? – Timothy Truckle Nov 23 '16 at 21:23
  • Right now i get some rows of the column will have 3 hosts and others will have 4. Not each row is filled out 3 columns wide or 4 columns wide – Flipflops Nov 23 '16 at 22:03
  • hint - seq 1 10 | paste - - - – iruvar Nov 23 '16 at 22:09
  • Can you show us a sample output? – NinjaGaiden Nov 24 '16 at 1:17
  • this should help: unix.stackexchange.com/a/308654/109046 – Sundeep Nov 24 '16 at 2:09
0

Lets say you have something like this

host1
host2
host3
host..99

You can do something like this

awk 'NR%3?ORS=" ":ORS="\n"' hosts

host1,host2,host3
host4,host5,host6
host7,host8,host9
host10,host11,host12
host13,host14,host15
host16,host17,host18
host19,host20,host21
host22,host23,host24
host25,host26,host27
host28,host29,host30
host31,host32,host33
host34,host35,host36
host37,host38,host39
host40,host41,host42
host43,host44,host45
host46,host47,host48
host49,host50,host51
host52,host53,host54
host55,host56,host57
host58,host59,host60
host61,host62,host63
host64,host65,host66
host67,host68,host69
host70,host71,host72
host73,host74,host75
host76,host77,host78
host79,host80,host81
host82,host83,host84
host85,host86,host87
host88,host89,host90
host91,host92,host93
host94,host95,host96
host97,host98,host99

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.