I have a string in variable and I would like to substitute it with another string, but the operation has no effect when the string being matched contains backslashes.
This is the part of the script that doesn't work:
cpuQueueOutput=`/usr/local/nagios/libexec/check_nrpe -H $hostname -t 30 -c Check_Pdh -a 'counter=\System\Processor Queue Length'`
echo "CPU Queue1: $cpuQueueOutput"
matchCpuQueueOutput="\System\Processor"
newCpuQueueOutput="CPU Queue"
CpuQueuePerf=`echo ${cpuQueueOutput//$matchCpuQueueOutput/$newCpuQueueOutput}`
echo "CPU Queue2: $CpuQueuePerf"
The output from the script looks like this:
CPU Queue1: OK: |'\System\Processor Queue Length_value'=0;0;0
CPU Queue2: OK: |'\System\Processor Queue Length_value'=0;0;0
OK: CPU Stats {(total, avg 1m: 9%), (total, avg 5m: 3%)} Top 3 Processes: {(powershell : 64%), (svchost#3 : 0%), (svchost#2 : 0%)} | 'total 1m'=9%;90;95 'total 5m'=3%;90;95
The substitution to replace OK: |'\System\Processor Queue Length_value'
by 'CPU Queue'
does not work.