I'm trying a few tests, in a shell script as below:
line="100:xx"
echo "$line" | grep -Po \\d+
result: 100
but,
line="100:xx"
echo `echo "$line" | grep -Po \\d+`
result is empty
Why?
Because backticks allow expansions like double quoted strings, one of your backslashes is being eaten too soon:
$ echo `echo "$line" | grep -Po \\d+ | cat`
$ echo `echo "$line" | grep -Po \\\d+`
100
That being said, just quote the regex
$ echo `echo "$line" | grep -Po '\d+'`
100
echo "$line"displaying the correct value? How about:line="100:xx" echo `echo "$line" | grep -Po \\d+`$()and they suck.echo `echo "$line" | grep -Po \\\\d+`orecho `echo "$line" | grep -Po '\\d+'`(But do switch to$(), backticks have been deprecated for a long time.)