Stupid shell stuff: prepending a character on each line

Bill Bogstad bogstad-e+AXbWqSrlAAvxtiuMwx3w at public.gmane.org
Sat Jan 9 19:14:00 EST 2010


On Sat, Jan 9, 2010 at 7:02 PM, Don Levey <lug-TwWeWiF2EGRi+ztankeudA at public.gmane.org> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> I'm trying to set up a proxy server at home, and make use of
> externally-prepared lists of sites to restrict.  Each list comes one
> site to a line, in the form "example.com" (no quotes, of course).
>
> The problem here is that for whatever reason squid doesn't like that
> format.  However, if I use ".example.com" with the initial dot, all is
> well with the world.  I've got things set up now so that each external
> list is downloaded, placed in the proper directory, and unzipped;
> apparently, I been to prepend the "." to each line.
>
> I'm sure something like sed or awk could do something like this, but my
> experience with them is limited to being able to spell them.  Does
> anyone have any suggestions for how I might accomplish this?  I'd prefer
> to keep the files in-place, but if I need to simply read the file line
> by line, cat the dot to each line, and output elsewhere then so be iit

sed 's/^/./' -i file-to-change

will add a period to the beginning of every line in the file 'file-to-change'.

I'm not sure if the '-i' option is available on all systems.

sed 's/^/./' < old-file > new-file

will generate a new, modified files on all systems.

Bill Bogstad






More information about the Discuss mailing list