Results 1 to 2 of 2
hello,
i have a very simple question:
can i put an output of a command in variables? (in bourne shell scripting)
if it could be, i would like to hear ...
- 05-12-2009 #1Just Joined!
- Join Date
- May 2009
- Location
- Israel
- Posts
- 1
a general question for bourne shell script
hello,
i have a very simple question:
can i put an output of a command in variables? (in bourne shell scripting)
if it could be, i would like to hear how.
thank you!
- 05-12-2009 #2Linux Guru
- Join Date
- Nov 2007
- Posts
- 1,695
Google: bash scripting "command substitution"
Command Substitution is a very handy feature of the bash shell. It enables you to take the output of a command and treat it as though it was written on the command line. For example, if you want to set the variable X to the output of a command, the way you do this is via command substitution.
There are two means of command substitution: brace expansion and backtick expansion.
Brace expansion workls as follows: $(commands) expands to the output of commands This permits nesting, so commands can include brace expansions
Backtick expansion expands `commands` to the output of commands.


Reply With Quote