Don't parse output of ls
, it is error prone in many ways.
You can use globbing with shopt globstar
:
shopt -s globstar
ls -1 **/RC*.TRI > filenames
globstar
, When enabled, the globbing code treats **
specially -- it matches all directories (and files within them, when appropriate) recursively.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…