# Decisions

Make a script choose: test values and files, and pick from a menu.

Updated: November 10, 2026

## [Choosing](https://www.ask-codey.com/courses/bash-in-depth/topics/bash-choosing)

1. [If This, Then That: if and \[\[ \]\]](https://www.ask-codey.com/lessons/bash-if-statements) (Apprentice): if lets a script choose: the commands after then run only when a test passes, \[\[ \]\] compares text with == and whole numbers with -lt and its friends, and if can also ask whether any command worked.
2. [Checking Before You Act: File Tests](https://www.ask-codey.com/lessons/bash-file-tests) (Apprentice): File tests let a script look before it acts: -e asks whether a path exists, -f and -d whether it's a file or a folder, -s whether a file has anything in it, and -nt whether it's newer than another.
3. [Menus and Choices: case and select](https://www.ask-codey.com/lessons/bash-case-and-select) (Apprentice): case matches one value against a list of patterns and runs the lines for the first match, which suits a script's options and yes-or-no answers, and select turns a list of words into a numbered menu.

## [Exercise: The Smart Backup](https://www.ask-codey.com/courses/bash-in-depth/topics/exercise-bash-the-smart-backup)

1. [Exercise: The Smart Backup](https://www.ask-codey.com/lessons/exercise-bash-the-smart-backup) (Apprentice): Finish a backup script that copies a file only when it's needed, with a usage line, --help, --list and a --pick menu, checks for missing, empty and folder names, and a clear message when a copy fails, while a check script runs it job by job.

Source: https://www.ask-codey.com/courses/bash-in-depth/chapters/bash-decisions
