Super User is a question and answer site for computer enthusiasts and power users. 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

I am checking a bash script which contains something like: export PATH=${PATH:+$PATH:}/usr/bin I assume it has same output as export PATH=$PATH:/usr/bin. I did a echo ${PATH:+$PATH:} it just output the value of $PATH plus a ':'. but if I modify it to ${PSOMETHING:+$PATH:}, it outputs nothing.

my question what's the different between using $PATH: and ${PATH:+$PATH:}? any benefit? how to understand the syntax?

share|improve this question
up vote 4 down vote accepted

See Parameter Expansion in man bash:


Use Alternate Value. If parameter is null or unset, nothing is substituted, other- wise the expansion of word is substituted.

share|improve this answer
I just found it on thanks anyways – Fivesheep Nov 4 '12 at 7:56

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.