Help | Site Map
Connecting Tech Pros Worldwide
Reply
 
LinkBack Thread Tools
  #1  
Old October 8th, 2008, 04:48 PM
Member
 
Join Date: Jun 2007
Posts: 45
Default what does :=0 mean in shell scripting

Hi,

Could anyone please let me know what does it mean by the following statement in solaris shell scripting.

$PROMPT " Select an option: "
read ans
db_option=${ans:=0}

I wanted to know the interpretation for this last line. what does it mean by :=0

Please let me know asap.
Reply
  #2  
Old October 8th, 2008, 06:34 PM
Newbie
 
Join Date: Oct 2008
Posts: 6
Default

One would think it means 'oh-no!!!'

Truth is, it is a bash shell construct for assigning a default value. In this case, it means 'if they don't give me a value, use zero'.

Google up bash-shell default-value for info, or see here, about 2/3's of the way down the page, for a default values title.

http://www.ibm.com/developerworks/library/l-bash-parameters.html?ca=drs-

The section offers a slightly technical recap that talks about :+, :-, := and :? Luckily, the more technical part is something most users won't need right away -- it gets into substitution timing (before or after using the default), and it also has a snippet of code you can experiment with until you get the hang of the nuances, *if you really need 'em*.

G'luck, mate.
Reply
Reply

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles