Counting a text pattern occurrence

suggest change

Using a pipe makes the output of a command the input of the next one.

ls -1 | grep -c "\.conf"

In this case the output of ls is used as the input of grep. The result will be the number of files that include “.conf” in their name.

This can be used to construct chains of subsequent commands as long as needed:

ls -1 | grep "\.conf" | grep -c .

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents