I know that we can assign the output of a command in a script as below:
res=$(ls) # assign the output of ls to res
Now I want to assign the error message to a variable:
res=$(XXXXXXX)
When I execute the script, which contains the code above, I get an error message on the terminal: command not found, whereas res
is still empty.
Is it possible to assign command not found
to res
while there is nothing shown on the terminal?