I am trying to make a bash script, really simple one, that comments out any line in file.txt that contains user input value, in my case email address.
The script looks like this:
#!/bin/bash
echo Unblock email account:
read email
sed -i '/$email/s/^/#/' file.txt
______________________________
- file.txt before running script:
user@example.com REJECT
__________________________________
- file.txt should look like this after running script:
#user@example.com REJECT
But it is not working, the file stays unchanged.
And if I execute sed -i
'/user@example.com/s/^/#/' file.txt in terminal, It does the job.
Any idea on how to get this work from script?
Tnx!