You need a shebang (e.g. #!/bin/sh
or #!/bin/bash
or whatever), but otherwise looks fine.
I’d probably also recommend wrapping anything with a variable in double quotes. I need to fix that example. I don’t know who wrote it, but I try to make all my examples pass shellcheck, so it couldn’t have been me. See some of the other examples for better practice in terms of using variables in shell scripts. (And, use shellcheck
to get good advice about safer and more reliable shell scripting.)