I would expect that the regular expression ^[a-z]*$ would not match random$something
However, this matches when I try it on the shell:
~# echo "random$something" | grep "^[a-z]*$"
random
~# echo "aaaaa$something" | grep "^a*$"
aaaaa
Why is this happening?
I’ve seen this on both Solaris and RedHat Linux.
Note that if you just do
without the grep, the result is
This is because the shell is trying to interpret $something as a variable.
If you change the double quotes to single quotes, you’ll see the expected behavior; that is no result.