Syntax

Bash Local Variable Syntax

In Bash, local variable: keeps a variable inside a function — local count=0

Quick Answer

Syntax
local count=0
BashSyntax

Local Variable

Code example
local count=0

Keeps a variable inside a function.

Learn More

How to local variable in Bash

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

Bash Local Variable Syntax

Use local count=0.

Related Syntax References

Frequently asked questions

What is the Bash syntax for local variable?

Use this pattern: local count=0

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