I used to test my Bash commands interactively on the CLI and then copy them over onto a SH script.This worked fine until today.Run the following on your command linea=008; echo ${a##*(0)}and you will get8run it in a script, and you'll get008And no, I am not drunk.What the heck is going on? O.oFrom the man pageIn order to understand what the comment add shopt -s extglob to your script mean, I report here a section from the man page.Another relevant man page section has been reported in the answer to the duplicate question.shopt [-pqsu] [-o] [optname ...]       Toggle  the  values of settings controlling optional shell behavior.       [...]       -s     Enable (set) each optname.       [...]       extglob If set, the extended pattern matching  features  described  above               under Pathname Expansion are enabled.
Bash pattern prefix removal script vs. interactive
bash;shell script;ubuntu;bash expansion;shopt