This is the exit status of the last executed command.
For example the command true
always returns a status of 0
and false
always returns a status of 1
:
true echo $? # echoes 0 false echo $? # echoes 1
From the manual: (acessible by calling man bash
in your shell)
$?
Expands to the exit status of the most recently executed foreground pipeline.
By convention an exit status of 0
means success, and non-zero return status means failure. Learn more about exit statuses on wikipedia.
There are other special variables like this, as you can see on this online manual: https://www.gnu.org/s/bash/manual/bash.html#Special-Parameters
Related Posts:
- How do I split a string on a delimiter in Bash?
- How can I sandbox Python in pure Python?
- How to mkdir only if a directory does not already exist?
- How to mkdir only if a directory does not already exist?
- How can I declare and use Boolean variables in a shell script?
- In a Bash script, how can I exit the entire script if a certain condition occurs?
- How can I declare and use Boolean variables in a shell script?
- “[ ]” vs. “[[ ]]” in Bash shell
- How do I split a string on a delimiter in Bash?
- Which characters need to be escaped when using Bash?
- What is the $? (dollar question mark) variable in shell scripting?
- Python script header
- Difference between a script and a program?
- Shell script not running, command not found
- How do I know the script file name in a Bash script?
- What is the difference between double and single square brackets in bash?
- What is “-bash: !”: event not found”
- Why use Chef/Puppet over shell scripts?
- How to use execvp()
- How to use execvp() to execute a command
- What is a reverse shell?
- Meaning of “! -S” in shell script
- “No such file or directory” but it exists
- How do I pause my shell script for a second before continuing?
- How do I tell if a regular file does not exist in Bash?
- How to execute a program or call a system command?
- In the shell, what does ” 2>&1 ” mean?
- How to run a PowerShell script
- Extract substring in Bash
- Where to place $PATH variable assertions in zsh?
- Ubuntu says “bash: ./program Permission denied” [closed]
- Should I put #! (shebang) in Python scripts, and what form should it take?
- Why do you need to put #!/bin/bash at the beginning of a script file?
- Should I put #! (shebang) in Python scripts, and what form should it take?
- In the shell, what does ” 2>&1 ” mean?
- How do I use a regex in a shell script?
- How do I copy a folder from remote to local using scp?
- How to concatenate string variables in Bash
- -bash: syntax error near unexpected token `)’
- How to grep for case insensitive string in a file?
- An example of how to use getopts in bash
- Difference between wait and sleep
- How do I parse command line arguments in Bash?
- Multi-line string with extra space (preserved indentation)
- How to run a PowerShell script
- How to delete from a text file, all lines that contain a specific string?
- Multi-line string with extra space (preserved indentation)
- ‘\r’: command not found – .bashrc / .bash_profile [duplicate]
- How can I recursively find all files in current and subfolders based on wildcard matching?
- How to perform grep operation on all files in a directory?
- Loop through an array of strings in Bash?
- ‘\r’: command not found – .bashrc / .bash_profile [duplicate]
- How can I check if a directory exists in a Bash shell script?
- How do I iterate over a range of numbers defined by variables in Bash?
- Why do people write #!/usr/bin/env python on the first line of a Python script?
- OS X: equivalent of Linux’s wget
- How to set ssh timeout?
- commands not found on zsh
- subprocess.Popen(): OSError: [Errno 8] Exec format error in python?
- How to substitute shell variables in complex text files
- sudo: apt-get: command not found
- How do I iterate over a range of numbers defined by variables in Bash?
- Why do people write #!/usr/bin/env python on the first line of a Python script?
- OS X: equivalent of Linux’s wget
- Using find to locate files that match one of multiple patterns
- How can I recursively find all files in current and subfolders based on wildcard matching?
- Curl command for https ( SSL )
- “unary operator expected” error in Bash if condition
- How to exclude a directory in find . command
- What does “-ne” mean in bash?
- “sed” command in bash
- How to reload .bashrc settings without logging out and back in again?
- Is there a Python equivalent to the ‘which’ command
- How to exclude a directory in find . command
- How to reload .bash_profile from the command line?
- What is the purpose of “&&” in a shell command?
- How to generate random number in Bash?
- Replace one substring for another string in shell script
- Shell command to tar directory excluding certain files/folders
- How to check if a variable is set in Bash?
- Shell Script Syntax Error: Unexpected End of File
- How does “cat << EOF" work in bash?
- Bash scripting missing ‘]’
- Pseudo-terminal will not be allocated because stdin is not a terminal
- How do I compare two string variables in an ‘if’ statement in Bash?
- adb shell su works but adb root does not
- Who can access a file with octal permissions “000” on Linux/UNIX?
- How can I compare numbers in Bash?
- What is a list in Bash?
- What does the line “#!/bin/sh” mean in a UNIX shell script?
- Open and write data to text file using Bash?
- How can I count all the lines of code in a directory recursively?
- How can I kill a process by name instead of PID, on Linux?
- Elegant way to search for UTF-8 files with BOM?
- Given two directory trees, how can I find out which files differ by content?
- adb shell su works but adb root does not
- How to remove the quotes when reading a variable in jq in shell?
- Shell script “for” loop syntax
- Diff command along with Grep gives “Binary file (standard input) matches”
- Shell: How to call one shell script from another shell script?