Syntax

Bash Script Arguments Syntax

In Bash, script arguments: reads arguments passed to a script — $1 $2 # all: "$@" count: $#

Quick Answer

Syntax
$1 $2 # all: "$@" count: $#
BashSyntax

Script Arguments

Code example
$1 $2 # all: "$@" count: $#

Reads arguments passed to a script.

Learn More

How to script arguments in Bash

  1. Open your Bash file or editor.
  2. Copy the example, then replace its sample names and values for your code.

Bash Script Arguments Syntax

Use $1 $2 # all: "$@" count: $#.

Related Syntax References

Frequently asked questions

What is the Bash syntax for script arguments?

Use this pattern: $1 $2 # all: "$@" count: $#

Can I copy this Bash code example?

Yes. Use Copy code and adapt the example to your program.

Is this Bash syntax different on Mac or Windows?

No. The language syntax is the same across operating systems.

Official source · How we verify