Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

If there is a colon (:) in the directory name, how could I add it to $PATH? [duplicate]

I am using mac os x, and I have some trouble setting the $PATH env. If the directory name is /path/to/add/a:b/bin, how can I add this directory to $PATH which is separated by :?

like image 974
eccstartup Avatar asked Feb 08 '14 02:02

eccstartup


People also ask

How do you put a colon in a file name?

On Windows systems, files and directory names cannot be created with a colon (:). But if a file or directory name is created with a colon on a Linux or Mac operating system, then moved to a Windows system, percent encoding is used to include the colon in the name in the index.

What Does a colon mean in a file path?

It is a colon-separated list of directories in which the shell looks for commands (see COMMAND EXECUTION below). A zero-length (null) directory name in the value of PATH indicates the current directory. A null directory name may appear as two adjacent colons, or as an initial or trailing colon.

What does colon mean in terminal?

The : (colon) command is used when a command is needed, as in the then condition of an if command, but nothing is to be done by the command. This command simply yields an exit status of zero (success).


1 Answers

As far as I know, you can't. The obvious way to escape a : character in $PATH would be to use a backslash, but a quick experiment with Bash on Linux indicates that it doesn't work. OSX might behave differently, but I suspect you'd have the same problem.

Your best bet is to rename the directory. If it really needs to have that name, you can create a symbolic link and add that to your $PATH:

 $ cd /path/to/add
 $ ln -s a:b a_b
 $ PATH="$PATH:/path/to/add/a_b/bin"
like image 135
Keith Thompson Avatar answered Oct 03 '22 06:10

Keith Thompson