Skip to content
Justice Tech School

local Variables

local limits a variable to the function. Without it variables are global.

Example
x=global
f() { local x=inner; echo "in: $x"; }
f
echo "out: $x"

Result

in: inner
out: global

Exercise

Function only variable.

 x=1

Quiz Test

What does local do?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.