Counting a text pattern occurrence
suggest changeUsing 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 .
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents