Search code examples
bashescapingfreebsdglob

Bash functions with globbing and substitution


I am trying to write a function in bash that will do a find for a directory containing the passed value. Something like this:

function dfind () {
   find / -type d -name "*$**"
}

What I want is for dfind test to execute find / -type d -name "*test*"

I've tried escaping the globbing *'s, or the quotes, or both, but I can't get it to work.


Solution

  • The problem is not the function nor bash, but something wonky on the machine I was using. Identical function works on another FreeBSD machine.