List files of particular extension

Solution 1:

Use find command instead

 find . -name "*.prj"

You can also combine the commands with find

find . -name "*.prj" -exec COMMAND {} \;

Hope this helps.

Solution 2:

Nothing, there is a limit on the number of argument bash can deal with. Do

ls | grep '\.prj$' | wc -l

Solution 3:

Parsing the output of ls is unreliable. It will probably work in your case, but ls mangles unprintable characters. Here is a fully reliable way of counting the files matching a certain extension. This shell snippet creates an array containing the file names, then prints the number of elements in the array.

shopt -s nullglob
a=(*.prj)
echo ${#a[@]}