Exit statuses fall between 0 and 255, though,  Likewise, functions within a script and the script itself return an exit status. # Exit status 0 returned because command executed  When a bash function ends its return value is its status: zero for success, non-zero for failure. IFS=- read -a words <<< $MY_TEXT for word in "${words[@]}"; do MY_INITIALS+=${word:0:1}; done ... With sort afile > afile this happens: The shell opens and truncates afile because of the file direction operation > afile The shell executes the sort program with one argument, afile, and binds stdout of the new process to the file descriptor opened in step 1. @NamGVU Returning rather than exiting is the correct thing to do. You can do this with an interactive session. Exit When Any Command Fails This can actually be done with a single line using the set builtin command with the -e option. Replace your boot2docker start with boot2docker start && $(boot2docker shellinit) and you are good to go. Extract minor version from kernel to bash variable, Evaluating variables from a list of names in bash, How to append entry the end of a multi-line entry using any of stream editors like sed or awk. A non-zero (1-255 values) exit status means command was a failure. You need to use regex's capture groups here to refer to the original [a-z] values. How can I run the Jenkins jobs through terminal? Bash get exit code of command – How to use exit codes in shell scripts. Every Linux command executed by the shell script or user, has an exit status. I have a while true loop that i use to monitor something. Terminate the current Powershell script. How do I set bash exit status in my Linux shell scripts? See “Bash Find out the exit codes of all piped commands” for more info. ./