Hi,
--- On Thu, Aug 9, 2012 at 9:09 PM, vivek poddar <[email protected]> wrote:
| I am new to shell scripts but trying to learn it by heart.
\--
If you learn it by heart, you will forget it. If you learn it with
practice and experience, you will remember for ever.
---
| 1. : ${HOME:-$HOME}
\--
The ':' is a built-in shell operator whose value is "true". In:
=== code.sh ===
#!/bin/sh
: ${TMPDAT:=/tmp/log.$$}
echo $TMPDAT
=== END ===
The value of TMPDAT, is say, /tmp/log.2324, you can override the value
in the command line:
$ TMPDAT=/tmp/tmp/log.txt sh code.sh
/tmp/tmp/log.txt
You cannot do that with explicit variable assignment as in the following:
---
| 2. HOME=$HOME
\--
This is basic parameter expansion where the value of the environment
variable HOME (right hand side) is assigned to the HOME variable (left
hand side).
SK
--
Shakthi Kannan
http://www.shakthimaan.com
--
Mailing list guidelines and other related articles: http://lug-iitd.org/Footer