Handy search hack
I find most search tools don’t think the way I do. Mostly I can roughly remember the name of the file or at least parts of it and what type of file it was. Thus I want to be able to search for various text snippets that I know were in the filename even if I didn’t remember the right order or dashes, underscores, etc. This little function does that for up to three snippets e.g. ”srch pdf microsoft spectrum” would find me that Microsoft report on spectrum re-use. You get the idea. Just stick the code below into your .bashrc file. I use this all the time.
function srch(){
if [ $3 ]; then
locate -i $1 | grep -i $2 | grep -i $3
elif [ $2 ]; then
locate -i $1 | grep -i $2
elif [ $1 ]; then
locate -i $1
else
echo "You must enter a search parameter\n"
fi
}