Bash Exit Codes

Bash Exit Codes

 Bash Exit Codes

The exit code is a number between 0 and 255. This is the value that returns to the parent process after the completion of a child's process. In other words, it denotes the exit status of the last command of our function.

The exit code value returns based on whether a command or program will successfully execute or not.

  • Success – A zero (0) value represents success.
  • failure – A non-zero exit code represents failure.


Write a program to write some content in /tmp/tesfile.txt file and check command is executed successfully or not.

Another Example

Write a program to search for a string in a file and check if the string is present or not.

This program will search if the string “test” present in /etc/passwd file.


Post a Comment