This finds a large number of files that are under various subdirectories of "Dropnot"
$ locate Dropnot
Can I find just the directory location with locate
? (which directory "Dropnot" is in)
So if Dropnot
is in /home/me/
, that's the only entry that gets returned.
If so, what's the simplest / shortest way ?
Preferably through a flag or symbol rather than piping out and greping for it, etc, but I'd take anything as an option.
Maybe some sort of Dropnot$ for end of line? (but didn't work).
Best Answer
There is no option to use
locate
to find selected type of file (like directory), but you can use syntax from your question -Dropnot$
to find lines that ends withDropnot
. For that you must use-e
option to locate to turn on POSIX regular expression.In this case you should use:
It is important what version of locate you have. In my system (Gentoo Linux) I have Secure Locate:
in which there is no
--basename
option fromuther
's answer. This option is provided by GNU Locate from findutils package:If you want to use regexp with GNU Locate you should use
-r
switch instead-e
.