I have a series of command to execute. However I need to exit whenever \'command is not found\' error occurs. So post execution check of output is not an option
The
If the command is not found, the exit status should be 127. However, you may be using bash 4 or later and have a function called command_not_found_handle defined. This function is called if a command cannot be found, and it may exit 0, masking the 127 code.
Running type command_not_found_handle will show the definition of the function if it is defined. You can disable it by running unset command_not_found_handle.