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?
- What is a reverse shell?
- “No such file or directory” but it exists
- How do I pause my shell script for a second before continuing?
- In the shell, what does ” 2>&1 ” mean?
- Where to place $PATH variable assertions in zsh?
- Should I put #! (shebang) in Python scripts, and what form should it take?
- Should I put #! (shebang) in Python scripts, and what form should it take?
- How do I use a regex in a shell script?
- An example of how to use getopts in bash
- 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)
- 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]
- OS X: equivalent of Linux’s wget
- How to set ssh timeout?
- 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?
- OS X: equivalent of Linux’s wget
- How can I recursively find all files in current and subfolders based on wildcard matching?
- What does “-ne” mean in bash?
- “sed” command in bash
- How to exclude a directory in find . command
- How to reload .bash_profile from the command line?
- How to generate random number in Bash?
- Replace one substring for another string in shell script
- How to check if a variable is set in Bash?
- Shell Script Syntax Error: Unexpected End of File
- Bash scripting missing ‘]’
- Pseudo-terminal will not be allocated because stdin is not a terminal
- adb shell su works but adb root does not
- Who can access a file with octal permissions “000” on Linux/UNIX?
- 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?
- Elegant way to search for UTF-8 files with BOM?
- Given two directory trees, how can I find out which files differ by content?
- How to remove the quotes when reading a variable in jq in shell?
- Diff command along with Grep gives “Binary file (standard input) matches”
- find: missing argument to -exec
- How do I set a variable to the output of a command in Bash?
- python getoutput() equivalent in subprocess
- screen Cannot open your terminal ‘/dev/pts/0’ – please check
- Is there a TRY CATCH command in Bash
- What is the difference between “#!/usr/bin/env bash” and “#!/usr/bin/bash”?
- How to convert a string to lower case in Bash?
- Is there a “goto” statement in bash?
- dquote> result of a execution a program in linux shell
- Using sudo with Python script
- Bash script: bad interpreter
- Command to change the default home directory of a user
- Sorting data based on second column of a file
- Remove all special characters except space from a string using JavaScript
- zip error – Nothing to do
- What does “&” at the end of a linux command mean?
- How to sort an array in Bash
- Run script on mac prompt “Permission denied”
- How do I get the current username in Windows PowerShell?
- * failed to open vchiq instance
- how to check which version of nltk, scikit learn installed?
- How to split one string into multiple strings separated by at least one space in bash shell?
- execvp: bad address error
- Using grep and ls -a commands
- How to use sed to extract substring
- Running shell command and capturing the output
- Simple PowerShell LastWriteTime compare
- How to get a shell environment variable in a makefile?
- What is a vertical tab?
- using rot13 and tr command for having an encrypted email address
- Shell Script: Execute a python program from within a shell script
- sed whole word search and replace
- Can pm2 run an ‘npm start’ script
- Integer expression expected error in shell script
- Shell command to monitor changes in a file
- What’s the difference betwen the single dash and double dash flags on shell commands?
- How to run command as user who has /usr/sbin/nologin as Shell?
- Adding a directory to $PATH in CentOS?
- How to let ‘cp’ command don’t fire an error when source file does not exist?
- How do I join two named pipes into single input stream in linux