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.

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

1 Answer 1

up vote 3 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 tldp.org/LDP/abs/html/parameter-substitution.html 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.