how to check if the argument contain wildcard (*,?) ?

In a script , i would like to check if the argument ( $1, $2 inside the script) contain wildcard (*,? etc). how do i do it?

> script_name arg1 arg*

$1 (arg1) does not contain wildcard, but $2 (arg* )contains wildcard. how can i tell in script?

i need to do this is because :

if arg1 (not contain *,? ) do ...
else (contain *,?...) do ....

clear?

thks

You didn't say which shell, so I picked ksh.

#! /usr/bin/ksh

for arg ; do
        echo testing arg = "$arg"
        if [[ $arg = *[*]* ]] ; then
                echo "$arg" contains at least one \*
        fi
        if [[ $arg = *[?]* ]] ; then
                echo "$arg" contains at least one \?
        fi
done
exit 0

NB, to run this you will probably need

./script one two\*

or something. If you don't escape the wildcard, the shell may expand it. If that happens, there is no way to recover the original command line.

Hi, I am stuck.. need help

I am writing a script that takes arguments. first check if the arguments contain wildcard (?,*) . if it contains , list it. if it doesn't contains, do something else (eg. cp it)

the problem is:

when i type
> script1 a*

the $@ contain : a, ab, aaa, abcd .....
and $1 is a, $2 is ab, $3 is aaa....

there is no such a variable is actually "a*" for me to check!!

I can turn off the 'noglob' by typing > set -o noglob
but, i can't do it IN A SCRIPT.

what other ways i can do this?

Help!

You already asked this question, and had it answered over here:
::merged threads - removed url::

It was also noted that the shell would replace that * with all the things it matched (if any) before sending it iff to the script, so there would not be a way to check for the presence of a "" unless it was escaped from the shell like this:
your_command a\
or
your_command 'a*'