# Key-Value Pair

*noun*

say it: **“KEE VAL-yoo PAIR”** **/ˈki ˈvæljuː ˈpɛr/**

One entry in a list that is looked up by name: the name, called the key, and what is stored under it, called the value.

## What is a **key-value pair** in a bash associative array?

A **key-value pair** is one slot of an associative array: a name, the key, and what's stored under it, the value. In `best[chill]="Window Down"`, `chill` is the key and `Window Down` the value. Each key appears once; storing under it again replaces the value.

```bash
declare -A best
best[chill]="Window Down"
best[upbeat]="Paper Lanterns"
echo "${#best[@]} pairs"   # 2 pairs
for mood in "${!best[@]}"; do echo "$mood: ${best[$mood]}"; done
# chill: Window Down
# upbeat: Paper Lanterns
```

## In a sentence

- “chill and Window Down make one **key-value pair** in the best array.”
- “The spending total has a **key-value pair** for food, bus and fun.”

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

Updated: November 10, 2026

## In other subjects

- [Key-Value Pair in C#](https://www.ask-codey.com/glossary/key-value-pair-c-sharp)
- [Key-Value Pair in Data Structures](https://www.ask-codey.com/glossary/key-value-pair-data-structures)
- [Key-Value Pair in JavaScript](https://www.ask-codey.com/glossary/key-value-pair-javascript)
- [Key-Value Pair in Python](https://www.ask-codey.com/glossary/key-value-pair)

Source: https://www.ask-codey.com/glossary/key-value-pair-unix
