Set bash variable to contain the output of command or process. Store process stdout

By neokrates, written on May 7, 2010

bash   snippet

  • Join date: 11-30-99
  • Posts: 224
View Counter:
  • 166 views
Rate it
Ad
Poll
  • Virtualized OS can be used for?

    View Results

    Loading ... Loading ...
Feeds:
  • bodytext bodytext bodytext

vat=$(my command)

Example: Store the output of which firefox and complain if no firefox installed.

1
2
3
4
5
  res=$(which firefox)
  if [ "" = "$res" ]; then
    echo "No firefox found"
    exit -1
  fi

Another way:
vat=`my command`

like:

  res=`which firefox`
Be Sociable, Share!
 
Does that help to solve your problem?
VN:F [1.8.5_1061]
Rating: 0 (from 0 votes)
0 votes 'YES'  0 votes 'NO'
TAGS
No tags for this post.
RELATED
Pages
Posts
SOCIAL
Be Sociable, Share!

Leave a Reply