Operating System - HP-UX
1829483 Members
1731 Online
109991 Solutions
New Discussion

pass parameter containing * to ksh script

 
Delvaux Ulrich
Occasional Contributor

pass parameter containing * to ksh script

Hello,
I need a ksh script that copies for example /usr/test/*.txt to /usr/backup/*.bck. I want to use this as parameter for my script but I have problems with the *. How can I manage to pass parameters containing *?
3 REPLIES 3
Dietmar Konermann
Honored Contributor

Re: pass parameter containing * to ksh script

Hi!

You need to protect the '*' from being interpreted by your calling shell.

This can be done e.g. using \ or quotes.

./script "/usr/test/*.txt" "/usr/backup/*.bck"
./script /usr/test/\*.txt /usr/backup/\*.bck

Regards...
Dietmar.
"Logic is the beginning of wisdom; not the end." -- Spock (Star Trek VI: The Undiscovered Country)
Deepak Extross
Honored Contributor

Re: pass parameter containing * to ksh script

You can turn off globbing with "set -f"
Once you issue a "set -f", * will not be expanded until you issue a "set +f"

Hope this helps.
Steve Steel
Honored Contributor

Re: pass parameter containing * to ksh script

Hi

The -f is good or
set -o noglob

Do it before you run the script and
set +f or set +o noglob

after.

-f Disables file name generation.

noglob Same as -f


steve steel

If you want truly to understand something, try to change it. (Kurt Lewin)