8

Can anyone please tell me what is mean by :- this symbol in Unix shell scripting

while [ ${runq:-$SLOTS} -ge $SLOTS ] in the given example

NaN
  • 7,441
  • 6
  • 32
  • 51
teepu
  • 266
  • 1
  • 6
  • 18
  • 1
    It's a bash thing - for providing default values - see e.g. http://jaduks.livejournal.com/7934.html – Paul R Jan 11 '16 at 12:16
  • 3
    @Paul It's not a bash thing, [it should work in any POSIX-compliant shell](http://pubs.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02_06_02). – Tom Fenech Jan 11 '16 at 12:28
  • @TomFenech: thanks for the clarification and the useful link - I'm not too familiar with shells other than bash. – Paul R Jan 11 '16 at 13:15
  • Removing the down vote. This is a valid question for new shell script users. – Pinaki Mukherjee Jan 11 '16 at 19:47
  • @PinakiMukherjee, ...however, downvotes are valid when a question "doesn't show research effort"; failing to search for duplicates before asking a new question qualifies. We already have one instance (actually, several) in the knowledgebase; adding more of them creates no value. – Charles Duffy Feb 17 '18 at 15:27

1 Answers1

4

This is a simple way to provide a default value using an expansion. See http://wiki.bash-hackers.org/syntax/pe#use_a_default_value for more information.

There are also answers to similar questions on stackoverflow like Read a variable in bash with a default value

Community
  • 1
  • 1
NaN
  • 7,441
  • 6
  • 32
  • 51