Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

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

when I create this alias from the command line everything works fine alias ejecta='for I in 1 2 3; do /usr/sbin/diskutil unmountDisk disk$I;done'

When the same alias is created in .bash_profile. the OS drops "$I"

THis is such a newbie question but I'm embarassed to say I cant find the solution. Do I have to create a sript and have the alias reference it ?

share|improve this question
did you use single or double quotes in your .bash_profile? – glenn jackman Feb 3 '12 at 20:42

What you are trying should work. The $I is probably being evaluated when your alias is being defined. Which probably means you are missing some quotes somewhere.

However, without including the relevant portion of your .bash_profile its hard to say.

share|improve this answer

In your question, you surround the alias with single quotes, which is the correct way to do it in order to delay evaluation of the variable. My guess is that you're using double quotes in your .bash_profile which allows the variable to be evaluated immediately. Since it's likely that the variable is unset at that point, it evaluates to a null string.

share|improve this answer
I was not using single quotes in the .bash_profile. I could have sworn I checked that. – Anthony Bouttell Feb 9 '12 at 21:09
@AnthonyBouttell: If you found this answer helpful, please mark it as accepted. Thanks. – Dennis Williamson Feb 9 '12 at 22:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .