if [ $(grep -c 'Health Status: RED' $LOG) -gt 0 ]; then
$(grep 'Server:' $LOG > $TMP )
while read -r line
do
echo "$instance,1,$line"
done < "$TMP"
else
echo "\n$instance,0,Health Status: GREEN\n"
fi
The output of above code is as follows:
Instance1,1,Server: EMEA
Instance1,1,Server: NAM
Instance1,1,Server: ASIA
Instance1,1,Server: AUSTRALIA
I need to add incremental space in $instance
variable per line, add one space after $instance
like below. Please note number of lines are not fixed.
Instance1 ,1,Server: EMEA ==> One blank space added after Instance1
Instance1 ,1,Server: NAM ==> two blank spaces added after Instance1
Instance1 ,1,Server: ASIA ==> three blank spaces added after Instance1
Instance1 ,1,Server: AUSTRALIA ==> four blank spaces added after Instance1
any inputs would be greatly appreciated.