I am building a home made catalog/indexer of my PDF/DJVU/EPUB/LIT/unspecified files. I need only index the file names. Indexing contents are not needed as I always keep descriptive file names. The locate command does a good job and outputs the results (after I build the index with updatedb).

However I would like to see only genuine files, not directories. Can I manipulate locate into such a behavior?

1 Answer 1


I'm not aware of any locate implementation that checks file types.

You can use Bash to filter the locate output:

while read -r -d $'\0' f
    [ -f "$f" ] && echo "$f"
done < <(locate -0 something)

Or you can use find with the -type f option:

find / -name something -type f

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .