Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. 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 saw this in the end of an awesome shell script but I can't understand the login here because I think it's being short-handed for a longer command.

spark ${@:-`cat`}

This apears at the end of this script. Any ideas?

+ Marks for some one who extends it into a full segment of code, even if its slower (Better for explanation)

share|improve this question
up vote 21 down vote accepted

It's the first special case of parameter substitution in man bash:

Use Default Values. If parameter is unset or null, the expansion of word is substituted. Otherwise, the value of parameter is substituted.

In the case you mentioned, either the user has provided arguments on the command line and they will be used, or the user is asked to input them on standard input afterwards.

share|improve this answer

Afaik :- is basically: use $@ OR `cat` ( without setting $@ to `cat` )...

so some variable substition thingy...

Edit: So it gives you some sort of interactive input...

Here's a little Terminal test:

localhost:~ _druu$ echo ${@:-`cat`}
^\hello world ;)
localhost:~ _druu$ 
share|improve this answer

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.