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/ ‘&’

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.