1. Home
  2. Bash
  3. Bash Tutorial
  4. Bash – Exit Codes

Bash – Exit Codes

Bash Exit Codes

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

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

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

Example

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

Another Example

Write a programme to search a string in a file and check if string present or not.

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

Was this article helpful to you? Yes 5 No 1
Advertisement