I have this script written. #!/bin/bashclearecho -e ---------------------------------------------------------------------echo -e | Client Name      | No. of Backups | Size    | Is Partial | Type    |echo -e ---------------------------------------------------------------------vcenter_name=$(cat /usr/local/vdr/etc/vcenterinfo.cfg | grep vcenter-hostname | cut -d '=' -f 2)client_list=$(avmgr getl --path=/$vcenter_name/VirtualMachines | awk '{print $2}' | tail -n+2)base=1073741824        for i in $client_list        do                number_of_backup=$(avmgr getb --path=/$vcenter_name/VirtualMachines/$i | tail -n+2 | wc -l)                size=$(avmgr getb --path=/$vcenter_name/VirtualMachines/$i --format=xml | sed 's/ /\n/g' | grep totalbytes | head -n 1 | cut -d '=' -f 2 | tr -d '' | cut -d '.' -f 1)                sizeInGB=$((size/base))GB                partial=$(avmgr getb --path=/$vcenter_name/VirtualMachines/$i --format=xml | sed 's/ /\n/g' | grep partial | cut -d '=' -f 2 | tr -d '' | head -n 1)                if [ $partial == 0 ]                then                    type=NO                else                    type=YES                fi                pid=$(avmgr getb --path=/$vcenter_name/VirtualMachines/$i --format=xml | sed 's/ /\n/g' | grep pidnum | cut -d '=' -f 2 | tr -d '' | head -n 1)                if [ $pid == 3016 ]                 then                    pidType=Windows                else                    pidType=Linux                fi                printf |  $(echo $i | cut -d '_' -f 1)           |       $number_of_backup        | $sizeInGB     | $type         | $pidType |\n        doneThe script runs great. But, the output is quite distorted:---------------------------------------------------------------------| Client Name      | No. of Backups | Size    | Is Partial | Type    |---------------------------------------------------------------------|  Test-Machine                |       1        | 2GB     | NO         | Linux ||  VM-A                |       3        | 1GB     | NO         | Windows ||  VM-B                |       3        | 1GB     | NO         | Windows ||  VM-C                |       3        | 1GB     | NO         | Windows ||  VM-D                |       3        | 0GB     | NO         | Windows |The main concern is the first column, Client Name. The names have variable length. Could we auto size the column 1 only depending on the client name. A max of 20 something characters would be the client name in this column. Many thanks. Suhas
Help with right column alignment.
bash;text formatting
Use printf:printf '%-20s|\n' 'abc' 'abcdefghijklmnop'Output:abc                 |abcdefghijklmnop    |In your case:    printf | %-20s | %14s | %4s | %10s | %7s |\n \       $(echo $i | cut -d '_' -f 1) $number_of_backup $sizeInGB $type $pidType