Skip to main content
added 7 characters in body
Source Link
MiniMax
  • 4.2k
  • 1
  • 21
  • 36

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

  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: cuthead -d:n -f111 virtual.txt | headcut -nd: 11-f1, gives us future column headers. The one Virtual Machine entry is first eleven lines, the cuthead separatescommand is used to get it. The virtual.txtcut splits this entry to two columns and print the only first column. The head command takes this column and output first eleven lines from itone.
    • command 2: sed 's/.*: //' virtual.txt - gives us 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

cat <(cut -d: -f1 virtual.txt | head -n 11) <(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

  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 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 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

cat <(head -n 11 virtual.txt | cut -d: -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

  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: head -n 11 virtual.txt | cut -d: -f1, gives us future column headers. The one Virtual Machine entry is first eleven lines, the head command is used to get it. The cut splits this entry to two columns and print the only first one.
    • command 2: sed 's/.*: //' virtual.txt - gives us 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
deleted 1 character in body
Source Link
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

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

  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 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 future column values. sed removes all unneeded text and leaves only values.
  2. xargs -d '\n' -n 11 - each. 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

cat <(cut -d: -f1 virtual.txt | head -n 11) <(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

  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 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 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

cat <(cut -d: -f1 virtual.txt | head -n 11) <(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

  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 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 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
added 176 characters in body
Source Link
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

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

  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

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

cat <(cut -d: -f1 virtual.txt | head -n 11) <(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

  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 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 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
Source Link
MiniMax
  • 4.2k
  • 1
  • 21
  • 36
Loading