Tuesday, March 07, 2006

CD dos path in unix environment

I am working under Windows, but I use cygwin in most of the time.
Sometimes, I have to change directory in cygwin to a path with UNC format (\\machine\path\to\xx)

I'm tired of typing the path myself, because in Unix, we have to use (//machine/path/to/xx) format.

Here comes a simple bash function to do all the conversion and change directory for me.
------------------------
function cddos () {
dos_path=$1;
cd `echo $dos_path | sed 's/\\\/\//g'`;
}
------------------------
Usage:
cddos '\\your\dos\path'

I love Bash function! It should be better to bash function instead of external bash script for such kind of small function.