it-artikel:how-to-find-files-by-separate-keywords-real-quick-using-locate-instead-of-find

How to find files by separate keywords real quick using 'locate' instead of 'find'?

If you have lots and lots if files accumulated over the decades , more or less organized, you sometimes need to find a file real quick. you might know some sort of keyword or partial filename , but cant remember where its located at. There you could go for some GUI or for the “find” command, to search your filesystems “live”. However, this often takes quiet some time. And you might want to search for a combination of keywords. And there most tools fail.

Since i had that problem several times, i developed this little solution for me. It makes use of the “locate” or “mlocate” package and searches the locate database real quick. It also searches for several keywords (AND).

To install it to your system just execute these few lines in your console:

sudo apt install locate -y
cat >> ~/.bashrc << EOF

# f - locates files real quick.
# only searches /home and /root for "files", which all contain 
# the cli argument words. (case INSENSITIVE)
# example:  f linux counter
function f { locate -i -A -b "$@" | grep -e ^/home/ -e ^/root ; }

EOF

Axel Werner 2018-09-17 06:04

it-artikel/how-to-find-files-by-separate-keywords-real-quick-using-locate-instead-of-find.txt · Last modified: 2018-09-17 06:14 by mail@awerner.myhome-server.de