Here is how you count the number of files outputted from any command using the ls command as an example

 $ ls -A | wc -l

This is a bit curious actually because ls -A doesn't necessarily print each file on each line but the line count is still equal to the number of files. I presume that this is because bash is deciding not create newlines where new line characters exist. There is a simple way to test to see if this is true. If we run

 $ ls -A > test.txt 

The output of ls -A will be sent into a file named test.txt instead of the wc program. After having done that we can run

 $ cat -E test.txt

which will represent each newline character with a $. And, as I have just found out, and as you'll be able to see, there is a $ after each file. Thus, when you run ls -A the newline characters are there, the shell just decides to not necessarily print each file to a newline