Session and utilities

The declare command

Declares or shows variables (and arrays) with their attributes.

Syntax

declare [opciones] [nombre=valor]

Most useful options

-aCreates an array
-iIntegers only
-pShows the variable

Copy-ready examples

$ declare COLOR=azulCreate a variable
$ echo ${COLOR}Read it

You can try them in the browser terminal: it does not touch your computer.

Typical mistakes

  • local (inside functions) and declare (global) are similar.

Related commands

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