Special characters in parameter

Hello,

I'm trying to write a simple (korn) shell script which is called from the command line with some parameters. But one of the parameter contains a "!" sign. For example:

myscript.ksh foo bar foo!bar

When I call the script like above I always get an error. So I tried to wrap the parameter with " signs or ' signs and also tried to escape the ! sign with a backslash. But I can't get it work ;(

So how can I pass a parameter with special characters in it to a script ? Of course also @#.:;_'" may be used.

Thanks, Lothar

You would need to properly quote the characters on the command line and put double quotes around variable references inside the script..

$ cat script
echo "$3"
$ ./script foo bar '!@#.:;_'\'\" 
!@#.:;_'"
2 Likes