cat <(cuthead -d:n -f111 virtual.txt | headcut -nd: 11-f1) <(sed 's/.*: //' virtual.txt) | xargs -d '\n' -n 11 | column -t
The number of lines per Virtual Machine is hardcoded in this case - 11. Will be better count it beforehand and store in to the variable, then use this variable in the code.
Explanation
cat <(command 1) <(command 2)-<()construction makescommandoutput appearing like a temporary file. Therefore,catconcatenates two files and pipes it further.- command 1:
cuthead -d:n -f111 virtual.txt | headcut -nd: 11-f1, gives us future column headers. The one Virtual Machine entry is first eleven lines, thecutheadseparatescommand is used to get it. Thevirtual.txtcutsplits this entry to two columns and print the only first column. Theheadcommand takes this column and output first eleven lines from itone. - command 2:
sed 's/.*: //' virtual.txt- gives us 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