我的命令输出可以列出 8 到 800 个主机。
我正在尝试弄清楚如何将其分成 3 或 4 列。
现在我正在使用“fmt | column”,但输出并不像我希望的那么整齐。
答案1
假设你有这样的东西
host1
host2
host3
host..99
你可以做这样的事情
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