How can I update the shell script where I can replace username "u1" to any value from user input in a .txt file
'username' => "u1"
echo "\nEnter Username to replace: "
sed -i -e s/u1/"$name"/g /var/1.txt
Try '$name' instead of "$name"
Best option is to use sed -i -r
sed -i -r 's/u1/'$name'/g' /var/1.txt
Another option you can try is save this to temp file and move it back
sed 's/u1/'$name'/g' /var/1.txt > /tmp/temp mv /tmp/temp /var/1.txt