echo -n "Username: "
read usernamert
echo -n "Password: "
read passwordt
echo -n "IP: "
read IPt
echo -n "Channel: "
read channelt
t1=$(echo "www://$usernamet:$passwordt@$IPt/TEST/SOMETHING?channel=$channelt1&TRUE=1")
sed -i "s "t_1", "t_2" "$t1", "AAA" g" test.txt
link should looks like www://username:password@$1.1.1.1/TEST/SOMETHING?channel=2&TRUE=1
so this kind of link i want to change with string in file test.txt
"t_1", "t_2"
but allways gets error. Where I mistake? I also tried to put variables in "" inside t1 variable, but didnt help.
CodePudding user response:
Your double quotes are delimiting the shell strings, not being used literally in the sed
pattern and replacement.
Put single quotes around the sed
operation, except for the variable.
sed -i 's "t_1", "t_2" "'"$t1"'", "AAA" g' test.txt