Arguments to scripts

Arguments to scripts work in exactly the same way they do for functions:

  • You can get the arguments as positional parameters with "$1", "$2", "$3", and so on
  • You can dynamically get all of the positional parameters without having to count them with "$@"
  • You can count the number of positional parameters if you need to with "$#"

Get Bash Quick Start Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.