🐧 Linux / Shell Scripting
Intermediate
What are special variables in bash?
Answer
Bash has several special variables with predefined meanings: $0 — script/shell name; $1-$9 — positional arguments; $# — argument count; $@ — all args as separate words; $* — all args as one word; $? — exit status of the last command (0=success, non-zero=failure); $$ — PID of the current shell; $! — PID of the last background process; $_ — last argument of the previous command; $- — current shell option flags; $IFS — Internal Field Separator (default: space/tab/newline). Understanding these is essential for robust scripting and error handling.