Paul
Paul

Reputation: 966

Make bash expand Wildcard in script command?

My script receives a wildcard as a parameter and I need to apply the find command on it. The problem is that if I don't quote the parameter, shell expands it relative to the current directory, but if I do, the find command doesn't expand it at all.

My code currently looks like this :

find /bin/"$1"

and $1 is *sh* If I run it as /bin/*sh* in terminal, it works as intended.

Upvotes: 0

Views: 167

Answers (1)

John Kugelman
John Kugelman

Reputation: 362037

The -name test is what expands wildcards when you use find. Try this:

find /bin/ -name "$1"

Upvotes: 3

Related Questions