I saw this in the end of an awesome shell script but I can't understand the logic 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)

  • The question which already has answer doesn't have explanation for @ which is what this question is about. This is definitely not duplicate question
    – Atul
    Dec 5, 2019 at 11:24

2 Answers 2


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.

  • 1
    What does it means when parameter is @ ?
    – Atul
    Dec 5, 2019 at 11:24

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$ 

Not the answer you're looking for? Browse other questions tagged .