0

The requirement is simple, but since I am not a linux expert and the available code from stackoverflow is not working, I need help. I have a parameter file for Information, in a specific row I have the below pattern:

$$REFRESH_LOAD_TIME=200

I need a shell script to update the 200 to a new value that is passed as an argument to the shell script. Below code is not working as expected.

#!/bin/bash
RefreshUTCDateTime="$1"
ParameterFileLocation ="$2"
sed -i 's/$$REFRESH_LOAD_TIME/$$REFRESH_LOAD_TIME=$RefreshUTCDateTime /g' $ParameterFileLocation*

Expected value post execution, when 100 is passed as an argument.

$$REFRESH_LOAD_TIME=100

I want through this A shell script to to change a value in a file with a parameter But it is not helping.

agc
  • 7,973
  • 2
  • 29
  • 50
rakesh jayaram
  • 63
  • 1
  • 10

1 Answers1

0
sed "s/\$\$REFRESH_LOAD_TIME.*/\$\$REFRESH_LOAD_TIME=$RefreshUTCDateTime /g" $ParameterFileLocation*

Brief explanation,

  • Variable expansion happens in double quotes.
  • And the dollar sign need to be escaped in sed for pattern substitution.
CWLiu
  • 3,913
  • 1
  • 10
  • 14