Some versions* of find
require that you provide a path argument which is a directory from which to start searching. Dot .
simply represents the current directory is is usually where you want to search.
You could replace this with any path that you want to be the base of the search. In some versions of find this can be left because the current directory is implied if no path argument is present.
You can run man find
in your shell for details about the arguments. For example the usage synopsis for mine indicates that the path argument is optional (inside square brackest []
):
find [-H] [-L] [-P] [-D debugopts] [-Olevel] [path...] [expression]
If you ran my find
with no arguments at all all files and directories starting from the current folder would be returned. Your example simply expressly states that the search should start from .
and includes the expression -name foo.txt
as one of the search filters.
* Notably all the BSD variants and anything sticking strictly to the POSIX standard. GNU find allows it to be optional.
path
is a required argument to find. – Caleb Aug 05 '11 at 13:20find
specification makes the behaviour unspecified if the first non-option argument starts with a-
or is afind
predicate allowing GNU find behaviour. A script that relies on the GNU find behaviour would be non-compliant though. – Stéphane Chazelas Dec 18 '15 at 12:46find "!" -print
to process the file or directory called "!". – Stéphane Chazelas Dec 18 '15 at 14:33find dir1 dir2 dir3 -name foo.txt
. – G-Man Says 'Reinstate Monica' Nov 11 '17 at 15:46