Basic questions re: bash
I've got a few pretty basic questions about bash. I came across the following link (http://trac.edgewall.org/ticket/4352) which has some variables listed as:
Code:
tracd=${TRACD-/usr/sbin/tracd} 2) When you assign a variable in a script as myvar=whatever, what's the difference between referring to $myvar and ${myvar} - what do the curly braces do? 3) When you assign a variable on the command line like myvar=whatever, what's the scope or lifetime of that 'myvar' variable? Is it for the lifetime of the shell, for all active logins under that shell, does it get saved somewhere? Thanks a lot. |
Quote:
Quote:
Code:
this_is_a_string_containing_the_$var_value Code:
this_is_a_string_containing_the_${var}_value Quote:
Anyway, check the export statement to see how variables can be inherited from the parent shell. Suppose you have a script (parent) which launches another script (child). If you export a variable in the parent script, its value is available to the child. This is the way by which environment variables like HOME and PATH are made available to all the scripts executed from the shell. Hope this helps. Good references to check: http://www.gnu.org/software/bash/manual/bashref.html http://www.tldp.org/LDP/abs/html/index.html |
You can also see what it does by executing it, as I have done here:
Code:
craptop3 ~ $ pidfile=${PIDFILE-/var/run/tracd.pid} |
All times are GMT -5. The time now is 02:16 PM. |