Find the answer to your Linux question:
Results 1 to 3 of 3
I want the output of command1 goes into variable A . For instance, if command1 = echo -n "148" , I want put 148 into A . I have done ...
  1. #1
    Just Joined!
    Join Date
    Jul 2007
    Location
    Italy
    Posts
    11

    Script: put the output of a command into a variable.

    I want the output of command1 goes into variable A .
    For instance, if command1 = echo -n "148" , I want put 148 into A .

    I have done some tries, but these doesn't work:
    Code:
    echo -n "148" > A
    echo -n "148" > A=
    echo -n "148" | A
    echo -n "148" | A=
    echo -n "148" |  read A
    ....etc
    Tks

  2. #2
    Linux Enthusiast
    Join Date
    Aug 2006
    Posts
    631
    To put the output of a command into a variable:

    Code:
    A=`command args`
    or

    Code:
    A=$(command args)
    To put a value into a variablele:

    Code:
    A=148
    Go here for some tutorials:


    http://www.tldp.org/LDP/Bash-Beginne...tml/index.html
    http://tldp.org/LDP/abs/html/
    Linux Shell Scripting Tutorial - A Beginner's handbook


    Regards

  3. #3
    Just Joined!
    Join Date
    Jul 2007
    Location
    Italy
    Posts
    11
    Thank you for all.

Posting Permissions

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