ls -R – Lists all files recursively.
ls a* – Lists all files matching pattern “a*”.
However: ls -R a* does not list all files in sub directories matching patter “a*”.
Why it happens
This happens because of specific implementation of linux. It’s the shell (ie Bash) that expands the “A*” to the names of all files/directories in the current directory that start with “A”, prior to passing the expansion result to “ls”.
So, let’s say I have, in my current directory: A1.txt A2.txt A3 – a subdirectory Than, “ls A*”, will actually be performed as “ls A1.txt A2.txt A3″ (“ls” gets 3 input parameters, not just the ‘A*’).
How to Fix
You cannot use ls to do recursive selective file listing. Instead use command “find”.
use: find . -name ‘A*’