Find the answer to your Linux question:
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 ...
  1. #1
    Just 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!

  2. #2
    Linux 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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...