useful sed scripts

A common problem – replace DOS line endings with Unix ones, across a bunch of files. (I had a dump from my old Windows work machine, which was not cooperating with CVS when I just copied it onto this machine). To type the ‘^M’ in Bash, type ctrl-V, then ctrl-M.

find . -type f -exec sed -i "s|^M$||g" {} \;

(Note that this version is safe for files which already have Unix line-endings, unlike one of the suggestions I found while searching.)

To update the cvs host across a working directory. (I have VPN access to the office but it seems to require fully qualified names).

find . -name Root -exec sed -i "s|:pserver:eharman@cvs:/cvs/virtuefusion|:pserver:eharman@cvs.virtuecasino.com:/cvs/virtuefusion|g" {} \;

(This assumes that the only files named ‘Root’ are the ‘CVS/Root’ ones – I checked on my system before running this, and it was true.)

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*