Let's say I'm in the Desktop directory and want to count the number of files and directories whose name is
exam. It should also count the files containing the string
exam. So to sum it up I need to:
- Count the directories with the name
- Count the files with the name and content
Here is what I've tried so far.
ls -l | grep -r "exam" | wc -l
But this command counts only files with the content
What if I have a couple of directories:
exam3, and a couple of .txt files
exam3.txt, and want to count them?