PDA

View Full Version : [SOLVED] add "." before all lines in a file using sed?



PryGuy
November 13th, 2008, 03:22 PM
Good day!
I need a hint! I have downloaded a restricted sites list (22918 sites) for my lovely squid, but they do not have the right syntax. I have to addd "." before all lines so they would look like '.site.com' not 'site.com'. Please give me a hint how do I do it in sed. Thank you, and I promise I'll finally manage myself to learn sed soon! :)

geirha
November 13th, 2008, 03:25 PM
Use '^' to match only the beginning of each line, and replace it with '.'. It's hard to only give a hint when it's such a short and easy sed :)

Also read about the -i option to sed in its man-page.

PryGuy
November 13th, 2008, 04:12 PM
got it, it's:
sed -i 's/^/./' filename