I would like to use sed with regex combination and pass variable to xargs command in this way:
$ cat test.txt
Rx_buffer_cap_tile=10000
Tx_buffer_cap_tile=10000
1132:1132:500:1132:4000
$ b=20000
$ d=8000
$ find . -type f -name test.txt -print0 | xargs -0 sed -i 's/.buffer_cap_tile=./.buffer_cap_tile=$b/g'
$ find . -type f -name test.txt -print0 | xargs -0 sed -i 's/500:1132:.*/500:1132:$d/g'
But the output is
Rx.buffer_cap_tile=$b0000
Tx.buffer_cap_tile=$b0000
1132:1132:500:1132:$d
The expected output is
Rx.buffer_cap_tile=10000
Tx.buffer_cap_tile=10000
1132:1132:500:1132:8000
How can I fix that?
P.S: If there are others ways like awk
or perl
, they are all accepted.
UPDATE:
The suggestion for using "
instead of '
works for variable expansion. However, considering the original
Rx_buffer_cap_tile=10000
Tx_buffer_cap_tile=10000
and using "s/.buffer_cap_tile=./.buffer_cap_tile=$b/g"
, the result is
Rx.buffer_cap_tile=200000000
Tx.buffer_cap_tile=200000000
Which is not correct.