Useful Bash Variables

Everytime I write a bash script, I have to look up one of these special bash variables and I always forget which one is which. Jotting it down so that I don’t have to google for them the next time.

  • $@ – all arguments as a big string.
  • $# – number of arguments passed in
  • $? – exit code of the last program
  • $$ – your process ID
  • $! – process ID of last program started w/ ‘&’

About Pratik Sinha

Linux Nerd, Socialist, Atheist, Adventuristic, Nature Lover, Geeky.

Leave a Reply