What are special variables in bash?

In bash, special variables are predefined variables that provide information about the script's execution environment. Here are some commonly used special variables:

  • $0: The name of the script.
  • $1, $2, $3, etc.: The first, second, third command-line arguments passed to the script.
  • $@: All command-line arguments passed to the script as a single word.
  • $#: The number of command-line arguments passed to the script.
  • $$: The process ID of the current shell or script.
  • $?: The exit status of the last command executed.

These variables are useful for handling input and controlling the flow of scripts.

0 Comments

no data
Be the first to share your comment!