Although the above two commands do actually answer the question I would like to present a less verbose output which satisfies the part:
to know which directory/file is checked by the find command no matter
the fact that it does or does not match the name I have set.
find /home/
-print
-type d -name "something"
Using the -print
expression.
As stated in the manual:
- If no expression is given, the expression -print is used by default as if it were put at the end of the command
find /home/ -type d -name "something"
- as if it were -->
find /home/ -type d -name "something" -print
but if you place the print expression at the beginning as follows
find /home/
-print
-type d -name "something"
- It will print out every file that is being checked
- of course the matched file will also be printed as it forms part of the checked files, but you do not have a way of knowing which one it was
If you place the print expression at the beginning and end:
find /home/
-print
-type d -name "something"
-print
- It will print out every file that is being checked
- It will print out every matched file aswell
So now the ones that matched will appear twice. Although a bit difficult to see if there are a lot of files.
So using the expression printf
instead of print
you can use
ANSI excape color codes within the format of the printf command, but as explainted in this answer the -printf
flag of find is different from the usual built-in from bash and "the color code sequence and the %p
needs to be in the same argument". This can lead to the following expression:
find /home/ -print -type d -name "something" -printf '\033[;34m%p\033[0m\n'
This will print the matches out in blue
more info available in the find man docs