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.
The -name
test is what expands wildcards when you use find
. Try this:
find /bin/ -name "$1"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.