Answer the question
In order to leave comments, you need to log in
How to delete a line containing certain text through the console?
I have a simple BASH that creates hosts for me.
echo "127.0.0.1 $newsite www.$newsite" >> /etc/hosts
sed -i '/$delsite/d' /etc/hosts
Answer the question
In order to leave comments, you need to log in
sed -i "/$delsite/d" /etc/hosts
but I don't advise you to do this - something will get into the variable and the file will get corrupted completely
make a file with a list of domains and a script to turn the list into a hosts file
to check this type of command, useecho sed -i "/$delsite/d" /etc/hosts
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question