I want to replace a string in a line of a document, with sed. Where the LINE Number value should come from a variable, $var.
I've tried:
sed '%ds/peer/md5/g' $var ./temp.txt
but it gives
sed: -e expression #1, char 1: unknown command: `%'
Also tried:
sed -e '"$var"s/peer/md5/g'-i ./temp.txt
sed: -e expression #1, char 1: unknown command: `"'
Finally tried:
printf '%ds/peer/md5/g;\n' 80 | sed -f - ./temp.txt
which prints correctly, but I can't save the result file with output redirection (>) or -i command.