What is the purpose of the $? variable in a shell script?

  • It represents the process ID of the script.
  • It stores the script's exit status.
  • It contains the script's standard input.
  • It holds the current working directory of the script.
The purpose of the $? variable in a shell script is to store the script's exit status. A value of 0 typically indicates success, while non-zero values indicate different types of errors or failures. This is essential for error checking and script control flow.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *