Session and utilities
The local command
Declares a local variable inside a function: it does not leak out.
Syntax
local nombre=valorCopy-ready examples
$ printf 'saluda() {\nlocal x=1\necho hola\n}\nsaluda\n' > f.shWrite a function$ bash f.shRun itYou can try them in the browser terminal: it does not touch your computer.
Typical mistakes
- local only makes sense inside a function.
FAQ
Learn to actually use it
The basic Linux course takes you from zero to console fluency with 24 self-grading lessons.
Start the free course