Skip to content

Instantly share code, notes, and snippets.

@qianjigui
Created April 21, 2014 07:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save qianjigui/11134972 to your computer and use it in GitHub Desktop.
Save qianjigui/11134972 to your computer and use it in GitHub Desktop.
Shell get the previous command's return status. 0 = success
#!/bin/bash
echo 'Error' > /abc.txt
echo $? #1
echo 'Pass'
echo $? #0
echo 'Pass' && echo 'Error' > /adc.txt && echo 'After Error'
echo $? #1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment