find "$dir" -name '*.sh' > /root/shFiles
Originally Posted by clvic
find "$dir" -name "*.sh" > /root/shFiles
should be what you are looking for
This one will work better.
Note the quotes around *.sh
If you put "*.sh", bash will replace with *.sh in current directory and find may try to find myscript.sh and only myscript.sh. With simple quotes, find correctly try to find anything that terminates whith sh.