LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   inserting program output into a variable (https://www.linuxquestions.org/questions/linux-general-1/inserting-program-output-into-a-variable-627878/)

MrFixit 03-13-2008 05:05 PM

inserting program output into a variable
 
Hello,
I know that with C Shell i can do this:

set var1=`some_command with_arguments`
and get in var1 the output of that command with these arguments...

is there a way to achieve this in Dash and Bash?

unSpawn 03-13-2008 05:28 PM

Skip the "set " part?

MrFixit 03-13-2008 05:42 PM

heh, sorry...
I had to use `./executable_name arguments` instead of `executable_name arguments`

now its fine, silly me...

matthewg42 03-13-2008 05:48 PM

You can use either of these:
Code:

variablename=`some command`
variablename=$(some command)



All times are GMT -5. The time now is 02:12 PM.