Purely parse the column from the bash command output
Solution 1:
It's possible to parse fixed-width columns with GNU awk:
The splitting of an input record into fixed-width fields is specified by assigning a string containing space-separated numbers to the built-in variable
FIELDWIDTHS
. Each number specifies the width of the field, including columns between fields. If you want to ignore the columns between fields, you can specify the width as a separate field that is subsequently ignored.
% awk -v FIELDWIDTHS="7 37 *" '{print $2}' foo
Name
DO-NOT-DELL
VMware vCenter Server
Auth-vcenter-Don't delete
VirtualMachine
Server 2005 for VM (dev team)
You can also use a regular expression as the field separator to split the text, so, e.g., using 3 or more spaces as the FS:
% awk -F ' {3,}' '{print $2}' foo
Name
DO-NOT-DELL
VMware vCenter Server
Auth-vcenter-Don't delete
VirtualMachine
Server 2005 for VM (dev team)
Solution 2:
I also found a good approach from one of my friend to get the list of the virtual machines.
# cat info.txt | tr -s " " | cut -d "[" -f1 | cut -d " " -f2- | tail -n +2
DO-NOT-DELL
VMware vCenter Server
Auth-vcenter-Don't delete
VirtualMachine
Server 2005 for VM (dev team)
Solution 3:
Convert spaces to tabs with non-default tab stop positions:
unexpand -t 7,44 info.txt | cut -f2