Jump to content

Storing command results into variables

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
2 replies to this topic

#1
BigLinux

BigLinux

    Learning Programmer

  • Members
  • PipPipPip
  • 46 posts
How do we store the result of a command executed into a variable? I am trying to store the value of "tty" command into a variable.

#2
DigitalLinx

DigitalLinx

    Newbie

  • Members
  • PipPip
  • 12 posts

var=`command`

echo $var



#3
asafe

asafe

    Programmer

  • Members
  • PipPipPipPip
  • 107 posts
var=$(command)
echo $var