Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

What are the advantages of aliasing a directory (in my .profile) as opposed to setting a shell variable to it (and exporting of course).

alias MY_DIR=/usr/local/data/test/


export MY_DIR
share|improve this question
up vote 4 down vote accepted

The alias only works for commands. That is, the shell will check argv[0] for aliases, it will check every part of argv for sigiled variables (like $MY_DIR). A visual demonstration:

g3 0 /home/jj33 > alias FOO=bar
g3 0 /home/jj33 > FOO
-ksh: bar: not found
g3 127 /home/jj33 > echo FOO
g3 0 /home/jj33 > BAZ=bar
g3 0 /home/jj33 > $BAZ
-ksh: bar: not found
g3 127 /home/jj33 > echo $BAZ
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.