I have figured out and tried replacing strings with the help of gsed -i
command like this:
gsed -i \'s/sdkUniqueKey=\"\"/sdkUniqueKey=\"123\"/g\
If I have properly understood your question, the following should do the trick:
#!/bin/bash
fileToBeRead="key.txt" #Whatever
var=$(tr -d '[:blank:]\n' < $fileToBeRead)
sed -i "s#sdkPrivateKey=\"\"#sdkUniqueKey=\"$var\"#g" AppConstants.txt
Since the key contains backslashes/slashes you should use a different separator for sed (e.g. #) or the sentence will be misparsed.
EDIT:
KEY="$var" perl -pi -e 's/sdkPrivateKey=""/sdkUniqueKey="$ENV{KEY}"/g' AppConstants.txt
perl
can be used instead of sed
in order to avoid sed
's separator issues. Check out @DennisWilliamson's comment below.