>_ IzzyLab

Topic breakdown

Bash has built-in regex matching via [[ string =~ pattern ]] — no separate grep needed for the check. The main idea is validating the entire string: without the anchors ^ and $, the pattern would match any substring, and abc123 would wrongly pass as "only digits". The [[ ... =~ ... ]] expression itself already returns 0 on a match and 1 on a mismatch, so its return code can be passed through as the script's result. Don't forget the shebang and the executable bit.

What's checked

  1. Script is executable
  2. Number accepted
  3. Non-number rejected
  4. The whole string is checked

What it looks like