Older shells use only glob for string matching file names and strings, like ksh ${name#pattern}.
Many traditional UNIX tools (ed/ex/vi/sed/grep/egrep/awk) use regex. Regex has layers of additional features, like grouping for OR (tom|dick) is only with grep-E/egrep, detecting word boundaries '\<word\>' or '\bWORD\b', back-references '\(.*\) \1'. You can google a lot on this, and if using regex libraries, look for a flag or set method like setExtended() if they are needed.
#!/bin/ksh
until [[ $# -qe 0 ]];do
if [[ "$1" =~ ^[0-9]+$ ]]; then
# Regex matched filename of only numbers.
fi
shift
done
Sometimes you have to use KSH to overcome the BASH pipe loop problem. For instance...
i=0
dept=()
find $deptroot -mindepth 1 -maxdepth 1 -type d | sort | while read x ;do
bn=$(basename "$x");
dept[$i]="$bn"
i=$(($i + 1))
echo "$i) $bn"
done
With BASH everything in the loop is inaccessible outside the loop because the pipe created a subprocess. That doesn't happen with KSH. $i is the number of departments found in KSH but 0 in BASH.
I'm sick and tired of the universe's ills being blamed on BASH. This is normal behavior for any garden-variety Bourne shell. ksh is the only shell I know offhand which can read out of a pipe -- this behavior can't be relied on unless you know you have ksh.
Some BASH constructs also allow you read text out of a loop. You can't rely on them unless you know you have BASH, of course.
read A B C <<< $(echo a b c)
You could also reorganize your code to process the relevant variables inside the subshell.
Thanks Chubler, I saw a similar work around with files but didn't know of the <( ) construct.
To Corona, I didn't say it was a bug and didn't blame the universe's problems on BASH. LOL Get yourself some Spaten Optimators or Paulaner Salvators and you'll feel better.