Updated: 11 October 2026 · Applies to: AlmaLinux 9, Rocky Linux 9, Ubuntu 24.04 and Debian 12
A first Bash script that uses a variable.
Steps
- Create
hello.sh:#!/usr/bin/env bash name="World" echo "Hello, $name!"
- Make it executable:
chmod +x hello.sh. - Run it:
./hello.sh.
Tip: Quote variables ("$name") so values with spaces work correctly.