Advertisement
mindthump

Bash special shell variables

Jul 19th, 2020 (edited)
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.67 KB | None | 0 0
  1. Variable    Meaning
  2. --------    -------
  3. $0          Filename of script
  4. $1 - $9     Positional parameters #1 - #9
  5. ${10}       Positional parameter #10
  6. $#          Number of positional parameters
  7. ${#*}       Number of positional parameters
  8. ${#@}       Number of positional parameters
  9. "$*"        All the positional parameters (as a single word) *
  10. "$@"        All the positional parameters (as separate strings)
  11. $?          Return value
  12. $$          Process ID (PID) of script
  13. $-          Flags passed to script (using set)
  14. $_          Last argument of previous command
  15. $!          Process ID (PID) of last job run in background
  16.  
  17. * Must be quoted, otherwise it defaults to $@.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement