Recover result of command in a variable
For specific reason, it is necessary to recover the result of a command (or back code) in variable to exploit the script later.
Below are different examples:
Syntax
var = $ (command)
Note: Please note that the old method using reverse quotes (`command`) is however forbidden and the examples presented here are better.
Examples
- Recovery of standard out
- stdout only
- stdout and stderr
- Recovery back code ($?)