Skip to main content
added 16 characters in body; edited title
Source Link

sed giving invalid arithmetic operator error - please help

sedsed keeps giving invalid arithmetic operator error. I am trying to assign the output of sed to a variable.

This one works, var=$(sed -e 's/"currentGeneration":5010/"currentGeneration":5011/' <<< $content )

var=$(sed -e 's/"currentGeneration":5010/"currentGeneration":5011/' <<< $content ) 

but when iI try to do the same with variable instead of 5010 and 5011, it fails with invalid arithmetic operator var=$((sed -e 's/"currentGeneration":$currg/"currentGeneration":$nextg/' <<< $content ))

var=$((sed -e 's/"currentGeneration":$currg/"currentGeneration":$nextg/' <<< $content )) 

I tried below also but it won't substitute anything. var=$(sed -e 's/"currentGeneration":$currg/"currentGeneration":$nextg/' <<< $content )

var=$(sed -e 's/"currentGeneration":$currg/"currentGeneration":$nextg/' <<< $content ) 

I am pretty sure I am missing something basic. Learning shell scripting on the job :(

sed giving invalid arithmetic operator error - please help

sed keeps giving invalid arithmetic operator error. I am trying to assign the output of sed to a variable.

This one works, var=$(sed -e 's/"currentGeneration":5010/"currentGeneration":5011/' <<< $content )

but when i try to do the same with variable instead of 5010 and 5011, it fails with invalid arithmetic operator var=$((sed -e 's/"currentGeneration":$currg/"currentGeneration":$nextg/' <<< $content ))

I tried below also but it won't substitute anything. var=$(sed -e 's/"currentGeneration":$currg/"currentGeneration":$nextg/' <<< $content )

I am pretty sure I am missing something basic. Learning shell scripting on the job :(

sed giving invalid arithmetic operator error

sed keeps giving invalid arithmetic operator error. I am trying to assign the output of sed to a variable.

This one works,

var=$(sed -e 's/"currentGeneration":5010/"currentGeneration":5011/' <<< $content ) 

but when I try to do the same with variable instead of 5010 and 5011, it fails with invalid arithmetic operator

var=$((sed -e 's/"currentGeneration":$currg/"currentGeneration":$nextg/' <<< $content )) 

I tried below also but it won't substitute anything.

var=$(sed -e 's/"currentGeneration":$currg/"currentGeneration":$nextg/' <<< $content ) 

I am pretty sure I am missing something basic. Learning shell scripting on the job :(

Source Link
Ram
  • 25
  • 4

sed giving invalid arithmetic operator error - please help

sed keeps giving invalid arithmetic operator error. I am trying to assign the output of sed to a variable.

This one works, var=$(sed -e 's/"currentGeneration":5010/"currentGeneration":5011/' <<< $content )

but when i try to do the same with variable instead of 5010 and 5011, it fails with invalid arithmetic operator var=$((sed -e 's/"currentGeneration":$currg/"currentGeneration":$nextg/' <<< $content ))

I tried below also but it won't substitute anything. var=$(sed -e 's/"currentGeneration":$currg/"currentGeneration":$nextg/' <<< $content )

I am pretty sure I am missing something basic. Learning shell scripting on the job :(