cat <(cut -d: -f1 virtual.txt | head -n 11) <(sed 's/.*: //' virtual.txt) | xargs -d '\n' -n 11 | column -t
Explanation
cat <(command 1) <(command 2)-<()construction makescommandoutput appearing like a temporary file. Therefore,catconcatenates two files and pipes it further.- command 1:
cut -d: -f1 virtual.txt | head -n 11, gives us the future column headers.cutseparatesvirtual.txtto two columns and print only first column. Theheadcommand takes this column and output first eleven lines from it. - command 2:
sed 's/.*: //' virtual.txt- gives us the future column values.sedremoves all unneeded text and leaves only values.
- command 1:
xargs -d '\n' -n 11- each input item is terminated by newline. This command gets items and prints them by 11 per line.column -t- is needed for pretty-printing displays. It displays our lines in a table form. Otherwise, each line will be different width.
Output
Virtual Machine ID Status Memory Uptime Server Pool HA Mode VCPU Type OS
OL6U5 0004fb00000600003da8ce6948c441bb Running 65536 17835 Minutes MyOVS1.vmorld.com HA-POOL false 16 Xen PVM Oracle Linux 6
OL6U6 0004fb00000600003da8ce6948c441bc Running 65536 17565 Minutes MyOVS2.vmorld.com NON-HA-POOL false 16 Xen PVM Oracle Linux 6
OL6U7 0004fb00000600003da8ce6948c441bd Running 65536 17835 Minutes MyOVS1.vmorld.com HA-POOL false 16 Xen PVM Oracle Linux 6