TCLUG Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [TCLUG:7556] bash programming basic
> 2: If a guy wanted to return the input from a command (such as 'date')
> to a script variable, what would be the best way to do it? I seem to
> have hit a brain block on this one. (I know -- it's a pretty newbie
> question.)
>
There are two ways to do it, they're both mentioned in man bash under the
"Command Substitution" section.
myvar=$(date)
-or-
myvar=`date`
If you use the second form, notice that those are backticks, rather than
apostrophes. On a PC keyboard, that's the character under the ~ . The
first way seems to be the preferred way to do it.
Chris