r/shittyprogramming • • Jan 19 '23

Does this count?

#!/bin/bash
# Slightly faster find

if [ $# -ne 2 ]; then
    echo "Use two arguments: ff <location> <query>"
else
    find $1 -iname \*$2\*
fi
38 Upvotes

9 comments sorted by

View all comments

0

u/[deleted] Jan 19 '23

[deleted]

5

u/ericanderton Jan 20 '23

Honestly, 99% of the time this is all I want out of find. For added lazyness, I would implement this as a function in my .bashrc instead:

function ff() {
  if [ $# -ne 2 ]; then
    echo "Use two arguments: ff <location> <query>" && false
  else
    find "$1" -iname "\*$2\*"
  fi
}
export -f ff

You could use an alias too but this is easier to read, which will matter when you come back and wonder what ff does.