Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. 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 was using openSUSE 11.3, it came with several aliases already set up. Two that I used a lot were + for pushd . and - for popd. Now on Debian, I can't figure out how to create the second one. alias -=popd tries to read -= as a command option to alias. I've tried putting quotes (both single and double) around it, and preceding it with a backslash, but I just keep getting error messages. Any suggestions?


share|improve this question
up vote 11 down vote accepted

try this:

alias -- -=popd

worked at least for me:

usr@srv % alias -- -=echo
usr@srv % - test
share|improve this answer
Thanks, works perfectly. What does the -- do, exactly? – Wolf Apr 24 '11 at 16:22
@Wolf: For most commands, -- marks the end of options; everything after it is arguments. For example, logger foo -x bar would log "foo bar" and treat -x as an option, while logger -- foo -x bar would treat it as an ordinary word in the message "foo -x bar". – grawity Apr 24 '11 at 16:58
The -- indicates that no more options follow on the command line, following -'s aren't interpreted as options. So this allows you to cat files that start with a - ;-) – binfalse Apr 24 '11 at 17:07
@grawity and @binfalse: Thanks for the explanation, that's very helpful! Very good to know. – Wolf Apr 24 '11 at 17:09

In bash you can create functions named as such:

+() { pushd "$@"; }
-() { popd "$@"; }
share|improve this answer
what is $@? – Lazer Apr 24 '11 at 16:54
@Lazer: In sh and bash, $@ expands to all arguments given to the function or script. Unquoted it works the same way as $*. When inside double quotes, however, it expands to exactly the same words as originally given, without any additional splitting. – grawity Apr 24 '11 at 17:05
@Lazer: $@ expands to all the parameters passed to the function (equivalent to "$1" "$2" ...). For more information, do man bash and search for Special Parameters. – André Paramés Apr 24 '11 at 17:05

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.