Special Parameters: Positional, IFS, and PATH

Updated

October 31, 2026

Special Parameters: Positional, IFS, and PATH

Bash reserves single-character parameters for tracking runtime state, command-line arguments, and environment boundaries:

Positional Arguments and $@ vs $*

Parameter Meaning Quoted Expansion
$0 Name of the script or shell "$0"
$1 .. $9 Individual positional arguments "$1"
${10} Arguments beyond 9 require braces "${10}"
$# Number of positional arguments "$#"
$@ All arguments as individual words "$@" expands to "$1" "$2" "$3" (Safe)
$* All arguments concatenated "$*" expands to "$1 $2 $3" joined by $IFS
# ALWAYS use "$@" when iterating over command-line arguments
for arg in "$@"; do
    echo "Processing: $arg"
done

Process & Runtime Parameters

  • $?: Exit status of the most recently executed foreground pipeline (0 = success).
  • $$: Process ID (PID) of the current shell.
  • $!: Process ID of the most recently spawned background process.
  • $_: The last argument of the previous command executed.