Parsing the output of ls
is considered bad practice. You can use find
:
find . -iname 'ABC*' | wc -l
man find
:
-iname pattern
Like -name, but the match is case insensitive. For example, the
patterns `fo*' and `F??' match the file names `Foo', `FOO',
`foo', `fOo', etc. In these patterns, unlike filename expan‐
sion by the shell, an initial '.' can be matched by `*'. That
is, find -name *bar will match the file `.foobar'. Please note
that you should quote patterns as a matter of course, otherwise
the shell will expand any wildcard characters in them.
As Johnsyweb notes in the comment, find
will recurse into subdirectories by default. To avoid that, you can supply -maxdepth 1
:
-maxdepth levels
Descend at most levels (a non-negative integer) levels of direc‐
tories below the command line arguments. -maxdepth 0
means only apply the tests and actions to the command line
arguments.