Adding to the front of a line

Lorenzo Luengo lluengo at dgeo.udec.cl
Tue Jan 20 03:48:21 UTC 2009


Matthew Flaschen escribió:
> Ray Parrish wrote:
>   
>> Hello,
>>
>> I've downloaded a text file of the new sites to block to avoid the 
>> conficker worm that is currently infecting Windows users, and would like 
>> to send it to my Windows using friends and family. However the file 
>> unfortunately has only the host names, one per line. I would like to add 
>> the 127.0.0.1 and a space to the front of each line in the file before I 
>> send it out, so all they have to do is copy and paste it's contents to 
>> the end of their hosts files.
>>     
>
> There are many ways.  Here's one:
>
> while read site; do
> echo "$site 127.0.0.1"
> done < sites.txt > output_file.txt
>
> Matt Flaschen
>
>   

I think the easiest is this

sed 's/^/127.0.0.1 /' myfile > mynewfile

-- 
Lorenzo Luengo Contreras
Administrador de Sistemas DGEO
Universidad de Concepción
Concepción - Chile
+56-41-2207277





More information about the ubuntu-users mailing list