I have list of domain in text file and I need to add 127.0.0.1 ip before the line in whole file. Example as below:
domain.txt
....
abc.com
...
I want to generate HOSTS file like
...
127.0.0.1 abc.com
...
In text file, I have thousand of domain entry.
Best Answer
You can achieve that with
sed
in the following way:Best make a backup of the file before, I'm right now not sure if you need to escape the space or not. To make a backup directly when you run sed you can use the following line:
A bit more information about
sed
you can find here.