bash - how to get the result of an echo into a variable
Here is how you assign what comes back from an echo statement to a bash variable.
How to assign the result of echo to a variable in bash script
MY_CHOICE=`echo $1 | tr "[:lower:]" "[:upper:]"`
Here is how you assign what comes back from an echo statement to a bash variable.
How to assign the result of echo to a variable in bash script
MY_CHOICE=`echo $1 | tr "[:lower:]" "[:upper:]"`
What I wanted to do was to set a variable in bash from a function. Not as easy as I would have hoped.
Returning values from bash functions
Here is the choice I used from the article:
The other way to return a value is to write your function so …
BASH command output to the variable has great examples of how to do this. Basically, it boils down to something like this:
variable=$(command)
variable=$(command [opotion...] arg1 arg2 ...)
variable=$(/path/to/command)
You can also use the "`" as well, with all the caveats of using it in bash entails …