Answer the question
In order to leave comments, you need to log in
How to delete lines containing words in bash?
Good day!
Please tell me how to delete a line containing a specific name, it is with a dot, through this script, it runs without errors, but the line is not deleted, and if executed directly from the console with the command sed -i 'domain.ru/d' /etc/pool/conf .py, then the line is deleted, it is necessary to delete the lines through the bash script
#!/bin/bash
echo "Enter domain":
read domain
sed -i '$domain/d' /etc/pool/conf.py
Answer the question
In order to leave comments, you need to log in
$ cat test.sh
#!/bin/bash
echo "Enter domain":
read domain
sed -i "/$domain/d" test.txt
cat test.txt
aaa.com
bbb.com
ccc.com
./test.sh
Enter domain:
bbb.com
cat test.txt
aaa.com
ccc.com
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question