Skip to main content
1 of 4
MiniMax
  • 4.2k
  • 1
  • 21
  • 36

cat <(cut -d: -f1 virtual.txt | head -n 11) <(sed 's/.*: //' virtual.txt) | xargs -d '\n' -n 11 | column -t

Explanation

  1. cat <(command 1) <(command 2) - <() construction makes command output appearing like a temporary file. Therefore, cat concatenates two files and pipes it further.

    • command 1: cut -d: -f1 virtual.txt | head -n 11, gives us the future column headers. cut separates virtual.txt to two columns and print only first column. The head command takes this column and output first eleven lines from it.
    • command 2: sed 's/.*: //' virtual.txt - gives us the future column values. sed removes all unneeded text and leaves only values.
  2. xargs -d '\n' -n 11 - each input item is terminated by newline. This command gets items and prints them by 11 per line.

  3. 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
MiniMax
  • 4.2k
  • 1
  • 21
  • 36