linux - replace specific char of a string using sed using shell script -


i have replace specific line of file other value. eg: have file content below:

request.timing=0/10 * * * * * ? 

now, want replace 10 (or specific, value in place) dynamic value. eg, if want replace 20, file should updated as:

request.timing=0/20 * * * * * ? 

can me? using sed below:

sed -i "s/request.timing=0\/??/request.timing=0\/$poller" 

where poller dynamic value pass.

$ echo 'request.timing=0/10 * * * * * ?' | sed -r 's:(request.timing=0/)[0-9]+:\1135:' request.timing=0/135 * * * * * ?  $ poller="135" $ echo 'request.timing=0/10 * * * * * ?' | sed -r 's:(request.timing=0/)[0-9]+:\1'"$poller"':' request.timing=0/135 * * * * * ? 

Comments