Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is meant by :- this symbol in unix shell scripting [duplicate]

Tags:

shell

unix

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

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

like image 620
teepu Avatar asked Jan 11 '16 12:01

teepu


People also ask

What does :- mean in bash?

It's a parameter expansion, it means if the third argument is null or unset, replace it with what's after :- $ x= $ echo ${x:-1} 1 $ echo $x $

What is the name of this symbol (#) in shell scripting?

# Comment or Trim Strings. Most often, you use the hash or number sign (#) to tell the shell what follows is a comment, and it should not act on it. You can use it in shell scripts and—less usefully—on the command line.

What is the meaning of 2 >& 1?

The 1 denotes standard output (stdout). The 2 denotes standard error (stderr). So 2>&1 says to send standard error to where ever standard output is being redirected as well.

What is :- in shell script?

It's the first special case of parameter substitution in man bash : ${parameter:-word} Use Default Values. If parameter is unset or null, the expansion of word is substituted. Otherwise, the value of parameter is substituted.


1 Answers

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

like image 52
NaN Avatar answered Sep 27 '22 18:09

NaN