-maxdepth is not implemented on all versions of find. beware. a suitable replacement for getting the number of *.txt files in the current directory is ls | egrep '\.txt$' |wc -l with the caveat that directory names that end in .txt will be falsely listed in the count.