thaynes2016_297
Aug 11, 2017Nimbostratus
bash assign tmsh output to variable
I have an issue I hope someone has ran accross.
I am attempting to get command output assigned to a variable. which works. But on the console, the command output is returned. I don't want to the output of the tmsh ltm ltm rule command to be displayed on the console, but I want it to be in the variable. of course > /dev/nul doesn't work because the output is suppressed.
its seems that only TMSH commands behave this way. If you look at my $rule you will see I use a command to set it as well.
strip leading space
rule=$(echo $rule | sed -e 's/^[ \t]*//')
OLDIFS=$IFS
IFS=$'\n'
getrule="$(tmsh list ltm rule ${rule})"
poolstocheck=()
for i in ${getrule[@]};
do :
if [[ $i == *"pool"* ]]; then
echo $i
fi
done