Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
add comment

2 Answers 2

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
add comment

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
add comment

Your Answer

 
discard

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.