Boston Linux & Unix (BLU) Home | Calendar | Mail Lists | List Archives | Desktop SIG | Hardware Hacking SIG
Wiki | Flickr | PicasaWeb | Video | Maps & Directions | Installfests | Keysignings
Linux Cafe | Meeting Notes | Blog | Linux Links | Bling | About BLU

BLU Discuss list archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Stupid shell stuff: prepending a character on each line



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







BLU is a member of BostonUserGroups
BLU is a member of BostonUserGroups
We also thank MIT for the use of their facilities.

Valid HTML 4.01! Valid CSS!



Boston Linux & Unix / webmaster@blu.org