what does ${VARIABLE:-0} stand for?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting what does ${VARIABLE:-0} stand for?
# 1  
Old 12-21-2009
Question what does ${VARIABLE:-0} stand for?

Hi all,

During reading the code, i met such expressment in a KSH script. I can not figure out what does this mean and don't know how to search it in the web. Could you please check below snippet and let me know what does this mean in a shell script:

Code:
VARIABLE=1
if [ ${VARIABLE:-0} -ne 1 ]; then
   . /bin/another_shell.sh
fi

I also met similiar situation before like:
Code:
${VARIABLE:-1}
${VARIABLE:-0/}

(may not exaclty like it, but there is definitely a slash at the end)

Thanks in Adv.

Last edited by zaxxon; 12-21-2009 at 03:44 AM.. Reason: use code tags please
# 2  
Old 12-21-2009
Hi.

It means:

Quote:
${parameter:-word}
Use Default Values. If parameter is unset or null, the expansion of word is substituted. Otherwise,
the value of parameter is substituted.
It's described in the man page.
# 3  
Old 12-21-2009
Explanation:-

Code:
${parameter-default}, ${parameter:-default}
If parameter not set, use default.

echo ${username-`whoami`}
# Echoes the result of `whoami`, if variable $username is still unset.

${parameter-default} and ${parameter:-default} are almost
equivalent. The extra : makes a difference only when parameter has been declared,
but is null.

SmilieSmilieSmilieSmilie
# 4  
Old 12-21-2009
Scttn, ahmad.diab,

Great thanks for your clear explanation...
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. IP Networking

Network stand still

**this was posted in another forum I suspect wrong one moved here **:confused: Hello all. Let me qualify my question by saying that I am struggling with how to ask the question I am semi green but have no issue reading up if pointed in the right direction. Please be gentle! A RHEL server 6.2.... (4 Replies)
Discussion started by: rsheikh01
4 Replies

2. Shell Programming and Scripting

What does the -z expression stand for?

What does - z and {} means if ; then echo "ERROR: \$ARBORDBU environment variable is not set\n" (8 Replies)
Discussion started by: rafa_fed2
8 Replies

3. HP-UX

Stand-alone start-up of HP-UX11i

I have a HP-UX11i machine on the network and that works fine. But, now i want to start this machine without network connection? How must i do this? Because, if i pull out the network cable it will not boot. (5 Replies)
Discussion started by: bavl
5 Replies

4. IP Networking

What does 'AF' of AF_INET stand for ?

as title. and how is it different from PF_INET ? also, any one knows sin_family , sin_port , sin_addr ..etc ? why are they called 'sin' ? finally, htons() host to network short , htonl() host to network long , ntohs() network to host short , ntohl() network to host long. why would... (6 Replies)
Discussion started by: trapeze
6 Replies

5. Programming

How to under stand the C code

#include <stdio.h> main(t,_,a) char *a; {return!0<t?t<3?main(-79,-13,a+main(-87,1-_, main(-86, 0, a+1 )+a)):1,t<_?main(t+1, _, a ):3,main ( -94, -27+t, a )&&t == 2 ?_<13 ?main ( 2, _+1, "%s %d %d\n" ):9:16:t<0?t<-72?main(_,... (4 Replies)
Discussion started by: brain_full
4 Replies

6. Shell Programming and Scripting

Can under stand the script

Hi all, I am working on following script which is already working and i am trying to understand but could not can any body help me in follwoing script. I understand that it deletes record from tables. using DB2 import from /dev/null. I dont know where in second portion it loads the data in to... (0 Replies)
Discussion started by: sam71
0 Replies

7. UNIX for Dummies Questions & Answers

stand alone wants to boot off network

Hello Everybody, I have a Sun Sparc 5 that used to have Solaris 8 on it. I wanted to build my skills at installing the software and then all went wrong for me. This computer is a stand alone, not networked at all. So I got my hands on Solaris 9 Sparc version, I went through the install and at... (1 Reply)
Discussion started by: oilpainter69
1 Replies

8. UNIX for Dummies Questions & Answers

OEM - what does this abbreviation stand for?

Just saw this OEM abbreviation during installation of Solaris 8. I'm curious to know what the letters stand for and what OEM actually is. (3 Replies)
Discussion started by: Kanu77
3 Replies

9. UNIX for Dummies Questions & Answers

No stand-by, keep on

How do you or what is the setup to keep the (server) up from shutting down? It is not server yet but it might very likely become to serve few clients. But, once I get in in the morning its off. It's Sparc, Solaris 8 and I would like to keep it running over night but once it is not attended it... (2 Replies)
Discussion started by: softarch
2 Replies
Login or Register to Ask a Question