Printing multi-line variable output into a single column
up vote
0
down vote
favorite
I have the following script in works:
#!/bin/bash
IFS=$(echo -en "nb")
echo -e "----------------------------------------------------------------------------------------------"
echo -e "| Job Name | Enabled | Client Names | Retention | Schedule | Type |"
echo -e "----------------------------------------------------------------------------------------------"
vcenter_name=$(cat /usr/local/vdr/etc/vcenterinfo.cfg | grep vcenter-hostname | cut -d '=' -f 2)
# To extract job names:
job_name=$(mccli group show --recursive=true | grep -i "/$vcenter_name/VirtualMachines" | awk -F/. '{print $(NF-2)}')
for i in $job_name
do
enabled=$(mccli group show --name=/$vcenter_name/VirtualMachines/$i | grep Enabled | awk '{print $NF}')
client_name=$(mccli group show-members --name=/vcenter-prod.happycow.local/VirtualMachines/$i | awk '{print $3}' | tail -n +4 | awk -F/ '{print $NF}')
printf "| %-27s | %7s | %7s | %10s | %7s | %12s |n" "$i" "$enabled" "$client_name"
done
The script runs great but needs some formatting.
The output I get now is:
----------------------------------------------------------------------------------------------
| Job Name | Enabled | Client Names | Retention | Schedule | Type |
----------------------------------------------------------------------------------------------
| Backup With Space | true | Space | | | |
| Disk-Level | true | | | | |
| Linux-VM | true | | | | |
| Partial | true | | | | |
| Prod-Backup | false | VM-B
VM-D | | | |
| Same-Host | true | | | | |
| Temp | true | esxi02
ESXi-6.5
ESXi6GA | | | |
I would like to see it as:
----------------------------------------------------------------------------------------------
| Job Name | Enabled | Client Names | Retention | Schedule | Type |
----------------------------------------------------------------------------------------------
| Backup With Space | true | Space | | | |
| Disk-Level | true | | | | |
| Linux-VM | true | | | | |
| Partial | true | | | | |
| Prod-Backup | false | VM-B | | | |
| VM-D | | | |
| Same-Host | true | | | | |
| Temp | true | esxi02
| ESXi6.5
| ESXi6GA | | | |
Ignore the |
alignment. I can take care of that one.
So basically, I would like to have the multi value / multi line output of job_name
variable under a single column.
bash shell
add a comment |
up vote
0
down vote
favorite
I have the following script in works:
#!/bin/bash
IFS=$(echo -en "nb")
echo -e "----------------------------------------------------------------------------------------------"
echo -e "| Job Name | Enabled | Client Names | Retention | Schedule | Type |"
echo -e "----------------------------------------------------------------------------------------------"
vcenter_name=$(cat /usr/local/vdr/etc/vcenterinfo.cfg | grep vcenter-hostname | cut -d '=' -f 2)
# To extract job names:
job_name=$(mccli group show --recursive=true | grep -i "/$vcenter_name/VirtualMachines" | awk -F/. '{print $(NF-2)}')
for i in $job_name
do
enabled=$(mccli group show --name=/$vcenter_name/VirtualMachines/$i | grep Enabled | awk '{print $NF}')
client_name=$(mccli group show-members --name=/vcenter-prod.happycow.local/VirtualMachines/$i | awk '{print $3}' | tail -n +4 | awk -F/ '{print $NF}')
printf "| %-27s | %7s | %7s | %10s | %7s | %12s |n" "$i" "$enabled" "$client_name"
done
The script runs great but needs some formatting.
The output I get now is:
----------------------------------------------------------------------------------------------
| Job Name | Enabled | Client Names | Retention | Schedule | Type |
----------------------------------------------------------------------------------------------
| Backup With Space | true | Space | | | |
| Disk-Level | true | | | | |
| Linux-VM | true | | | | |
| Partial | true | | | | |
| Prod-Backup | false | VM-B
VM-D | | | |
| Same-Host | true | | | | |
| Temp | true | esxi02
ESXi-6.5
ESXi6GA | | | |
I would like to see it as:
----------------------------------------------------------------------------------------------
| Job Name | Enabled | Client Names | Retention | Schedule | Type |
----------------------------------------------------------------------------------------------
| Backup With Space | true | Space | | | |
| Disk-Level | true | | | | |
| Linux-VM | true | | | | |
| Partial | true | | | | |
| Prod-Backup | false | VM-B | | | |
| VM-D | | | |
| Same-Host | true | | | | |
| Temp | true | esxi02
| ESXi6.5
| ESXi6GA | | | |
Ignore the |
alignment. I can take care of that one.
So basically, I would like to have the multi value / multi line output of job_name
variable under a single column.
bash shell
1. a report script like this would be better written entirely inawk
orperl
(or anything else but sh or bash) - trying to do it in bash will result in an unreadable mess. BTW,perl
has great built-in report writing capabilities (seeman perlform
). 2. we need to sample input, not just the desired output. 3. some basic bash/shell tips: useIFS=$'nb'
, notIFS=$(echo "nb")
; there's no need to pipe cat into grep or grep into awk - both are capable of reading files withoutcat
's help. e.g.vcenter_name=$(awk -F= '{print $2}' /usr/local/vdr/etc/vcenterinfo.cfg)
– cas
Aug 2 '17 at 3:56
Thanks. Still learning things in bash, thanks for the input on better scripting. :)
– suhas savkoor
Aug 2 '17 at 18:21
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have the following script in works:
#!/bin/bash
IFS=$(echo -en "nb")
echo -e "----------------------------------------------------------------------------------------------"
echo -e "| Job Name | Enabled | Client Names | Retention | Schedule | Type |"
echo -e "----------------------------------------------------------------------------------------------"
vcenter_name=$(cat /usr/local/vdr/etc/vcenterinfo.cfg | grep vcenter-hostname | cut -d '=' -f 2)
# To extract job names:
job_name=$(mccli group show --recursive=true | grep -i "/$vcenter_name/VirtualMachines" | awk -F/. '{print $(NF-2)}')
for i in $job_name
do
enabled=$(mccli group show --name=/$vcenter_name/VirtualMachines/$i | grep Enabled | awk '{print $NF}')
client_name=$(mccli group show-members --name=/vcenter-prod.happycow.local/VirtualMachines/$i | awk '{print $3}' | tail -n +4 | awk -F/ '{print $NF}')
printf "| %-27s | %7s | %7s | %10s | %7s | %12s |n" "$i" "$enabled" "$client_name"
done
The script runs great but needs some formatting.
The output I get now is:
----------------------------------------------------------------------------------------------
| Job Name | Enabled | Client Names | Retention | Schedule | Type |
----------------------------------------------------------------------------------------------
| Backup With Space | true | Space | | | |
| Disk-Level | true | | | | |
| Linux-VM | true | | | | |
| Partial | true | | | | |
| Prod-Backup | false | VM-B
VM-D | | | |
| Same-Host | true | | | | |
| Temp | true | esxi02
ESXi-6.5
ESXi6GA | | | |
I would like to see it as:
----------------------------------------------------------------------------------------------
| Job Name | Enabled | Client Names | Retention | Schedule | Type |
----------------------------------------------------------------------------------------------
| Backup With Space | true | Space | | | |
| Disk-Level | true | | | | |
| Linux-VM | true | | | | |
| Partial | true | | | | |
| Prod-Backup | false | VM-B | | | |
| VM-D | | | |
| Same-Host | true | | | | |
| Temp | true | esxi02
| ESXi6.5
| ESXi6GA | | | |
Ignore the |
alignment. I can take care of that one.
So basically, I would like to have the multi value / multi line output of job_name
variable under a single column.
bash shell
I have the following script in works:
#!/bin/bash
IFS=$(echo -en "nb")
echo -e "----------------------------------------------------------------------------------------------"
echo -e "| Job Name | Enabled | Client Names | Retention | Schedule | Type |"
echo -e "----------------------------------------------------------------------------------------------"
vcenter_name=$(cat /usr/local/vdr/etc/vcenterinfo.cfg | grep vcenter-hostname | cut -d '=' -f 2)
# To extract job names:
job_name=$(mccli group show --recursive=true | grep -i "/$vcenter_name/VirtualMachines" | awk -F/. '{print $(NF-2)}')
for i in $job_name
do
enabled=$(mccli group show --name=/$vcenter_name/VirtualMachines/$i | grep Enabled | awk '{print $NF}')
client_name=$(mccli group show-members --name=/vcenter-prod.happycow.local/VirtualMachines/$i | awk '{print $3}' | tail -n +4 | awk -F/ '{print $NF}')
printf "| %-27s | %7s | %7s | %10s | %7s | %12s |n" "$i" "$enabled" "$client_name"
done
The script runs great but needs some formatting.
The output I get now is:
----------------------------------------------------------------------------------------------
| Job Name | Enabled | Client Names | Retention | Schedule | Type |
----------------------------------------------------------------------------------------------
| Backup With Space | true | Space | | | |
| Disk-Level | true | | | | |
| Linux-VM | true | | | | |
| Partial | true | | | | |
| Prod-Backup | false | VM-B
VM-D | | | |
| Same-Host | true | | | | |
| Temp | true | esxi02
ESXi-6.5
ESXi6GA | | | |
I would like to see it as:
----------------------------------------------------------------------------------------------
| Job Name | Enabled | Client Names | Retention | Schedule | Type |
----------------------------------------------------------------------------------------------
| Backup With Space | true | Space | | | |
| Disk-Level | true | | | | |
| Linux-VM | true | | | | |
| Partial | true | | | | |
| Prod-Backup | false | VM-B | | | |
| VM-D | | | |
| Same-Host | true | | | | |
| Temp | true | esxi02
| ESXi6.5
| ESXi6GA | | | |
Ignore the |
alignment. I can take care of that one.
So basically, I would like to have the multi value / multi line output of job_name
variable under a single column.
bash shell
bash shell
edited 2 days ago
Rui F Ribeiro
38.2k1475125
38.2k1475125
asked Aug 1 '17 at 21:04
suhas savkoor
104116
104116
1. a report script like this would be better written entirely inawk
orperl
(or anything else but sh or bash) - trying to do it in bash will result in an unreadable mess. BTW,perl
has great built-in report writing capabilities (seeman perlform
). 2. we need to sample input, not just the desired output. 3. some basic bash/shell tips: useIFS=$'nb'
, notIFS=$(echo "nb")
; there's no need to pipe cat into grep or grep into awk - both are capable of reading files withoutcat
's help. e.g.vcenter_name=$(awk -F= '{print $2}' /usr/local/vdr/etc/vcenterinfo.cfg)
– cas
Aug 2 '17 at 3:56
Thanks. Still learning things in bash, thanks for the input on better scripting. :)
– suhas savkoor
Aug 2 '17 at 18:21
add a comment |
1. a report script like this would be better written entirely inawk
orperl
(or anything else but sh or bash) - trying to do it in bash will result in an unreadable mess. BTW,perl
has great built-in report writing capabilities (seeman perlform
). 2. we need to sample input, not just the desired output. 3. some basic bash/shell tips: useIFS=$'nb'
, notIFS=$(echo "nb")
; there's no need to pipe cat into grep or grep into awk - both are capable of reading files withoutcat
's help. e.g.vcenter_name=$(awk -F= '{print $2}' /usr/local/vdr/etc/vcenterinfo.cfg)
– cas
Aug 2 '17 at 3:56
Thanks. Still learning things in bash, thanks for the input on better scripting. :)
– suhas savkoor
Aug 2 '17 at 18:21
1. a report script like this would be better written entirely in
awk
or perl
(or anything else but sh or bash) - trying to do it in bash will result in an unreadable mess. BTW, perl
has great built-in report writing capabilities (see man perlform
). 2. we need to sample input, not just the desired output. 3. some basic bash/shell tips: use IFS=$'nb'
, not IFS=$(echo "nb")
; there's no need to pipe cat into grep or grep into awk - both are capable of reading files without cat
's help. e.g. vcenter_name=$(awk -F= '{print $2}' /usr/local/vdr/etc/vcenterinfo.cfg)
– cas
Aug 2 '17 at 3:56
1. a report script like this would be better written entirely in
awk
or perl
(or anything else but sh or bash) - trying to do it in bash will result in an unreadable mess. BTW, perl
has great built-in report writing capabilities (see man perlform
). 2. we need to sample input, not just the desired output. 3. some basic bash/shell tips: use IFS=$'nb'
, not IFS=$(echo "nb")
; there's no need to pipe cat into grep or grep into awk - both are capable of reading files without cat
's help. e.g. vcenter_name=$(awk -F= '{print $2}' /usr/local/vdr/etc/vcenterinfo.cfg)
– cas
Aug 2 '17 at 3:56
Thanks. Still learning things in bash, thanks for the input on better scripting. :)
– suhas savkoor
Aug 2 '17 at 18:21
Thanks. Still learning things in bash, thanks for the input on better scripting. :)
– suhas savkoor
Aug 2 '17 at 18:21
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
One approach is the following where we make use of nroff
and tbl
. We first generate the code for the tbl
preprocessor based on the data.
Since I don't have access to your utilities so I have modeled your program behavior on the following, which you'd have to then incorporate in your case:
#!/bin/bash
NL=$'n'
TAB=$'t'
header=( "Job Name" "Enabled" "Client Names" "Retention" "Schedule" "Type" )
job_name=( "Backup With Space" "Disk-Level" "Linux-VM" "Partial" "Prod-Backup" "Same-Host" "Temp" )
enabled=( true true true true false true true )
client=( Space "" "" "" "VM_B${NL}VM_D" "" "esxio2${NL}ESXi-6.5${NL}ESXi6GA" )
{
echo .TS
echo allbox,center,tab($'t');
echo l r l l l l l.
echo "$(IFS=$'t'; echo "${header[*]}")"
for (( i=0; i<${#enabled[@]}; i++ ))
do
var=${client[$i]//$NL/$NL$TAB$TAB}
printf '%st%st%stttn' "${job_name[$i]}" "${enabled[$i]}" "${var}"
done
echo .TE
} | tbl - | nroff -Tascii -ms | grep '.'
Results:
+------------------+---------+--------------+-----------+----------+------+
|Job Name | Enabled | Client Names | Retention | Schedule | Type |
+------------------+---------+--------------+-----------+----------+------+
|Backup With Space | true | Space | | | |
+------------------+---------+--------------+-----------+----------+------+
|Disk-Level | true | | | | |
+------------------+---------+--------------+-----------+----------+------+
|Linux-VM | true | | | | |
+------------------+---------+--------------+-----------+----------+------+
|Partial | true | | | | |
+------------------+---------+--------------+-----------+----------+------+
|Prod-Backup | false | VM_B | | | |
+------------------+---------+--------------+-----------+----------+------+
| | | VM_D | | | |
+------------------+---------+--------------+-----------+----------+------+
|Same-Host | true | | | | |
+------------------+---------+--------------+-----------+----------+------+
|Temp | true | esxio2 | | | |
+------------------+---------+--------------+-----------+----------+------+
| | | ESXi-6.5 | | | |
+------------------+---------+--------------+-----------+----------+------+
| | | ESXi6GA | | | |
+------------------+---------+--------------+-----------+----------+------+
Thanks for all the suggestions. I was able to get this done by adding a loop for the client list and add "" to ignore additional values. Thanks.
– suhas savkoor
Aug 2 '17 at 18:20
+1. nice, i was thinking of doing something similar with markdown but got distracted by real life.
– cas
Aug 2 '17 at 18:31
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
One approach is the following where we make use of nroff
and tbl
. We first generate the code for the tbl
preprocessor based on the data.
Since I don't have access to your utilities so I have modeled your program behavior on the following, which you'd have to then incorporate in your case:
#!/bin/bash
NL=$'n'
TAB=$'t'
header=( "Job Name" "Enabled" "Client Names" "Retention" "Schedule" "Type" )
job_name=( "Backup With Space" "Disk-Level" "Linux-VM" "Partial" "Prod-Backup" "Same-Host" "Temp" )
enabled=( true true true true false true true )
client=( Space "" "" "" "VM_B${NL}VM_D" "" "esxio2${NL}ESXi-6.5${NL}ESXi6GA" )
{
echo .TS
echo allbox,center,tab($'t');
echo l r l l l l l.
echo "$(IFS=$'t'; echo "${header[*]}")"
for (( i=0; i<${#enabled[@]}; i++ ))
do
var=${client[$i]//$NL/$NL$TAB$TAB}
printf '%st%st%stttn' "${job_name[$i]}" "${enabled[$i]}" "${var}"
done
echo .TE
} | tbl - | nroff -Tascii -ms | grep '.'
Results:
+------------------+---------+--------------+-----------+----------+------+
|Job Name | Enabled | Client Names | Retention | Schedule | Type |
+------------------+---------+--------------+-----------+----------+------+
|Backup With Space | true | Space | | | |
+------------------+---------+--------------+-----------+----------+------+
|Disk-Level | true | | | | |
+------------------+---------+--------------+-----------+----------+------+
|Linux-VM | true | | | | |
+------------------+---------+--------------+-----------+----------+------+
|Partial | true | | | | |
+------------------+---------+--------------+-----------+----------+------+
|Prod-Backup | false | VM_B | | | |
+------------------+---------+--------------+-----------+----------+------+
| | | VM_D | | | |
+------------------+---------+--------------+-----------+----------+------+
|Same-Host | true | | | | |
+------------------+---------+--------------+-----------+----------+------+
|Temp | true | esxio2 | | | |
+------------------+---------+--------------+-----------+----------+------+
| | | ESXi-6.5 | | | |
+------------------+---------+--------------+-----------+----------+------+
| | | ESXi6GA | | | |
+------------------+---------+--------------+-----------+----------+------+
Thanks for all the suggestions. I was able to get this done by adding a loop for the client list and add "" to ignore additional values. Thanks.
– suhas savkoor
Aug 2 '17 at 18:20
+1. nice, i was thinking of doing something similar with markdown but got distracted by real life.
– cas
Aug 2 '17 at 18:31
add a comment |
up vote
1
down vote
One approach is the following where we make use of nroff
and tbl
. We first generate the code for the tbl
preprocessor based on the data.
Since I don't have access to your utilities so I have modeled your program behavior on the following, which you'd have to then incorporate in your case:
#!/bin/bash
NL=$'n'
TAB=$'t'
header=( "Job Name" "Enabled" "Client Names" "Retention" "Schedule" "Type" )
job_name=( "Backup With Space" "Disk-Level" "Linux-VM" "Partial" "Prod-Backup" "Same-Host" "Temp" )
enabled=( true true true true false true true )
client=( Space "" "" "" "VM_B${NL}VM_D" "" "esxio2${NL}ESXi-6.5${NL}ESXi6GA" )
{
echo .TS
echo allbox,center,tab($'t');
echo l r l l l l l.
echo "$(IFS=$'t'; echo "${header[*]}")"
for (( i=0; i<${#enabled[@]}; i++ ))
do
var=${client[$i]//$NL/$NL$TAB$TAB}
printf '%st%st%stttn' "${job_name[$i]}" "${enabled[$i]}" "${var}"
done
echo .TE
} | tbl - | nroff -Tascii -ms | grep '.'
Results:
+------------------+---------+--------------+-----------+----------+------+
|Job Name | Enabled | Client Names | Retention | Schedule | Type |
+------------------+---------+--------------+-----------+----------+------+
|Backup With Space | true | Space | | | |
+------------------+---------+--------------+-----------+----------+------+
|Disk-Level | true | | | | |
+------------------+---------+--------------+-----------+----------+------+
|Linux-VM | true | | | | |
+------------------+---------+--------------+-----------+----------+------+
|Partial | true | | | | |
+------------------+---------+--------------+-----------+----------+------+
|Prod-Backup | false | VM_B | | | |
+------------------+---------+--------------+-----------+----------+------+
| | | VM_D | | | |
+------------------+---------+--------------+-----------+----------+------+
|Same-Host | true | | | | |
+------------------+---------+--------------+-----------+----------+------+
|Temp | true | esxio2 | | | |
+------------------+---------+--------------+-----------+----------+------+
| | | ESXi-6.5 | | | |
+------------------+---------+--------------+-----------+----------+------+
| | | ESXi6GA | | | |
+------------------+---------+--------------+-----------+----------+------+
Thanks for all the suggestions. I was able to get this done by adding a loop for the client list and add "" to ignore additional values. Thanks.
– suhas savkoor
Aug 2 '17 at 18:20
+1. nice, i was thinking of doing something similar with markdown but got distracted by real life.
– cas
Aug 2 '17 at 18:31
add a comment |
up vote
1
down vote
up vote
1
down vote
One approach is the following where we make use of nroff
and tbl
. We first generate the code for the tbl
preprocessor based on the data.
Since I don't have access to your utilities so I have modeled your program behavior on the following, which you'd have to then incorporate in your case:
#!/bin/bash
NL=$'n'
TAB=$'t'
header=( "Job Name" "Enabled" "Client Names" "Retention" "Schedule" "Type" )
job_name=( "Backup With Space" "Disk-Level" "Linux-VM" "Partial" "Prod-Backup" "Same-Host" "Temp" )
enabled=( true true true true false true true )
client=( Space "" "" "" "VM_B${NL}VM_D" "" "esxio2${NL}ESXi-6.5${NL}ESXi6GA" )
{
echo .TS
echo allbox,center,tab($'t');
echo l r l l l l l.
echo "$(IFS=$'t'; echo "${header[*]}")"
for (( i=0; i<${#enabled[@]}; i++ ))
do
var=${client[$i]//$NL/$NL$TAB$TAB}
printf '%st%st%stttn' "${job_name[$i]}" "${enabled[$i]}" "${var}"
done
echo .TE
} | tbl - | nroff -Tascii -ms | grep '.'
Results:
+------------------+---------+--------------+-----------+----------+------+
|Job Name | Enabled | Client Names | Retention | Schedule | Type |
+------------------+---------+--------------+-----------+----------+------+
|Backup With Space | true | Space | | | |
+------------------+---------+--------------+-----------+----------+------+
|Disk-Level | true | | | | |
+------------------+---------+--------------+-----------+----------+------+
|Linux-VM | true | | | | |
+------------------+---------+--------------+-----------+----------+------+
|Partial | true | | | | |
+------------------+---------+--------------+-----------+----------+------+
|Prod-Backup | false | VM_B | | | |
+------------------+---------+--------------+-----------+----------+------+
| | | VM_D | | | |
+------------------+---------+--------------+-----------+----------+------+
|Same-Host | true | | | | |
+------------------+---------+--------------+-----------+----------+------+
|Temp | true | esxio2 | | | |
+------------------+---------+--------------+-----------+----------+------+
| | | ESXi-6.5 | | | |
+------------------+---------+--------------+-----------+----------+------+
| | | ESXi6GA | | | |
+------------------+---------+--------------+-----------+----------+------+
One approach is the following where we make use of nroff
and tbl
. We first generate the code for the tbl
preprocessor based on the data.
Since I don't have access to your utilities so I have modeled your program behavior on the following, which you'd have to then incorporate in your case:
#!/bin/bash
NL=$'n'
TAB=$'t'
header=( "Job Name" "Enabled" "Client Names" "Retention" "Schedule" "Type" )
job_name=( "Backup With Space" "Disk-Level" "Linux-VM" "Partial" "Prod-Backup" "Same-Host" "Temp" )
enabled=( true true true true false true true )
client=( Space "" "" "" "VM_B${NL}VM_D" "" "esxio2${NL}ESXi-6.5${NL}ESXi6GA" )
{
echo .TS
echo allbox,center,tab($'t');
echo l r l l l l l.
echo "$(IFS=$'t'; echo "${header[*]}")"
for (( i=0; i<${#enabled[@]}; i++ ))
do
var=${client[$i]//$NL/$NL$TAB$TAB}
printf '%st%st%stttn' "${job_name[$i]}" "${enabled[$i]}" "${var}"
done
echo .TE
} | tbl - | nroff -Tascii -ms | grep '.'
Results:
+------------------+---------+--------------+-----------+----------+------+
|Job Name | Enabled | Client Names | Retention | Schedule | Type |
+------------------+---------+--------------+-----------+----------+------+
|Backup With Space | true | Space | | | |
+------------------+---------+--------------+-----------+----------+------+
|Disk-Level | true | | | | |
+------------------+---------+--------------+-----------+----------+------+
|Linux-VM | true | | | | |
+------------------+---------+--------------+-----------+----------+------+
|Partial | true | | | | |
+------------------+---------+--------------+-----------+----------+------+
|Prod-Backup | false | VM_B | | | |
+------------------+---------+--------------+-----------+----------+------+
| | | VM_D | | | |
+------------------+---------+--------------+-----------+----------+------+
|Same-Host | true | | | | |
+------------------+---------+--------------+-----------+----------+------+
|Temp | true | esxio2 | | | |
+------------------+---------+--------------+-----------+----------+------+
| | | ESXi-6.5 | | | |
+------------------+---------+--------------+-----------+----------+------+
| | | ESXi6GA | | | |
+------------------+---------+--------------+-----------+----------+------+
answered Aug 2 '17 at 6:25
user218374
Thanks for all the suggestions. I was able to get this done by adding a loop for the client list and add "" to ignore additional values. Thanks.
– suhas savkoor
Aug 2 '17 at 18:20
+1. nice, i was thinking of doing something similar with markdown but got distracted by real life.
– cas
Aug 2 '17 at 18:31
add a comment |
Thanks for all the suggestions. I was able to get this done by adding a loop for the client list and add "" to ignore additional values. Thanks.
– suhas savkoor
Aug 2 '17 at 18:20
+1. nice, i was thinking of doing something similar with markdown but got distracted by real life.
– cas
Aug 2 '17 at 18:31
Thanks for all the suggestions. I was able to get this done by adding a loop for the client list and add "" to ignore additional values. Thanks.
– suhas savkoor
Aug 2 '17 at 18:20
Thanks for all the suggestions. I was able to get this done by adding a loop for the client list and add "" to ignore additional values. Thanks.
– suhas savkoor
Aug 2 '17 at 18:20
+1. nice, i was thinking of doing something similar with markdown but got distracted by real life.
– cas
Aug 2 '17 at 18:31
+1. nice, i was thinking of doing something similar with markdown but got distracted by real life.
– cas
Aug 2 '17 at 18:31
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f383282%2fprinting-multi-line-variable-output-into-a-single-column%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1. a report script like this would be better written entirely in
awk
orperl
(or anything else but sh or bash) - trying to do it in bash will result in an unreadable mess. BTW,perl
has great built-in report writing capabilities (seeman perlform
). 2. we need to sample input, not just the desired output. 3. some basic bash/shell tips: useIFS=$'nb'
, notIFS=$(echo "nb")
; there's no need to pipe cat into grep or grep into awk - both are capable of reading files withoutcat
's help. e.g.vcenter_name=$(awk -F= '{print $2}' /usr/local/vdr/etc/vcenterinfo.cfg)
– cas
Aug 2 '17 at 3:56
Thanks. Still learning things in bash, thanks for the input on better scripting. :)
– suhas savkoor
Aug 2 '17 at 18:21