Let\'s imagine I have a bash script, where I call this:
bash -c \"some_command\" do something with code of some_command here
Is it possible to
Here's an illustration of $? and the parenthesis subshell mentioned by Paggas and Matti:
$?
$ (exit a); echo $? -bash: exit: a: numeric argument required 255 $ (exit 33); echo $? 33
In the first case, the code is a Bash error and in the second case it's the exit code of exit.
exit