# declare

*noun*

say it: **“dih-KLAIR”** **/dɪˈklɛr/**

A bash command that makes a variable and says what kind it is, such as an array found by names.

## What does **declare** do in bash?

`declare` makes a variable and says what kind it is. `declare -A` (read "declare associative") makes an associative array, which no other line can do; without it, names in brackets all land in slot 0. Inside a function, `declare` makes the variable the function's own, the way `local` does.

```bash
declare -A best
best[chill]="Window Down"
best[upbeat]="Paper Lanterns"
echo "${best[chill]}"   # Window Down
```

## In a sentence

- “Inside a function, **declare** makes the variable the function's own.”
- “Sam forgot **declare** -A, and every mood landed in slot 0.”

Level: Freelancer · [More Unix terms at this level](https://www.ask-codey.com/glossary?category=unix&level=4)

Updated: November 10, 2026

Source: https://www.ask-codey.com/glossary/declare
