Skip to content

Instantly share code, notes, and snippets.

@martinhj
Last active June 3, 2019 11:30
Show Gist options
  • Save martinhj/a49f24cf71662b5607bf8a0e6eb1c32d to your computer and use it in GitHub Desktop.
Save martinhj/a49f24cf71662b5607bf8a0e6eb1c32d to your computer and use it in GitHub Desktop.
Shell special parameters
# from https://stackoverflow.com/questions/5163144/what-are-the-special-dollar-sign-shell-variables
# Aslo see https://www.gnu.org/software/bash/manual/html_node/Special-Parameters.html
$1# (, $2, $3 , ...) are the positional parameters.
"$@" # is an array-like construct of all positional parameters, {$1, $2, $3 ...}.
"$*" # is the IFS expansion of all positional parameters, $1 $2 $3 ....
$# # is the number of positional parameters.
$- # current options set for the shell.
$$ # pid of the current shell (not subshell).
$_ # most recent parameter (or the abs path of the command to start the current shell immediately after startup).
$IFS # is the (input) field separator.
$? # is the most recent foreground pipeline exit status.
$! # is the PID of the most recent background command.
$0 # is the name of the shell or shell script.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment