On the manual page of locate
, I read this:
locate --basename
Match only the base name against the specified patterns.
This is the opposite of --wholename.
but I don't get it. What does it mean? What is the difference between locate --basename
and locate --wholename
? Can you give me some simple examples?
Best Answer
The basename is the last part of the full path
By default
locate
matches a pattern anywhere in the path.With
-b
(basename) it matches only paths where the pattern appears in the last part of the pathname, the filename or directory name itself.For example, output from
locate gimp
would includeAnd many other things, but
locate -b gimp
would findWithout including the subdirectories, since there is no
gimp
string in their basenames.