Just an illustration:
first
cd /usr/lib
and run
for x in $(ls);do if [ "$x" == "*.a" ];then echo $x;fi;done
What I want to do is to select files with extension .a and print them. I know there are much simpler way of doing this, but that is not my intention here.
The problem is that the command above doesn't work. I don't know why. I learn this from this post
I also tried
[ "$x" == *.a ] bash: [: too many arguments
[ $x = "*.a" ] shows nothing
[ $x = *.a ] bash: [: too many arguments
I know [[ $x == *.a ]]
works, but I want to know what is the correct way to write [
test in this case?