I want to remove ${} among arithmetic form in the file using sed for example abc=$(( ${var}+3 )) to abc=$(( var+3 ))
I'm using positional swapping in sed something like
sed -E 's/(\w+\W\$\(\( ) (\$\{) (\w+) (\}) (.*)/\1 \3 \5/g file.txt'
but it extracts only abc=3 when I use
echo abc=$((( ${var}+3 )) | sed -E 's/(\w+\W\$\(\( ) (\$\{) (\w+) (\}) (.*)/\1 \3 \5/'
in terminal, just to check if it works all right
and it did nothing on shell script how can I remove only ${} part of the file?
I am using Mac OS and also tried on Ubuntu but it was still the same
$(( ${abc} + 12))
is, indeed$((abc + 12))
. But$((${1}+1))
is not$((1+1))
. Or, more convoluted example,$(({abc}0+12))
is not$((abc0+12))
(if abc=15 and abc0=20, first one is 162, second one is 32).$((...))
expression use positional arguments, or concatenation