How to check if a command succeeded? - Ask Ubuntu
askubuntu.com › questions › 29370Mar 07, 2011 · Show activity on this post. If you only need to know if the command succeeded or failed, don't bother testing $?, just test the command directly. E.g.: if some_command; then printf 'some_command succeeded ' else printf 'some_command failed ' fi. And assigning the output to a variable doesn't change the return value (well, unless it behaves ...