mike628
mike628

Reputation: 49351

Quote argument strings Shell

Can I quote arguments that have spaces or special chars in the command line? If not, how is this handled. We have one argument that is a multiword string. I'm sure this has been asked many times, but I cant find it.

./myscript name=bob occupation=guy who does stuff

Upvotes: 0

Views: 50

Answers (1)

Wald
Wald

Reputation: 1091

You can use quotes. Something like:

$ var='abc def'
$ echo "$var"
abc def

You can read more here.

Your case example (note I'm calling the script that needs the multiword string from the another script in this example):

sh ./test.sh 'this is a test'

test.sh contains echo $1 and prints this is a test. Hope this solution works.

Upvotes: 1

Related Questions