views:

131

answers:

2

Alright, I have a script that takes a few arguments, runs data, and then rsyncs the data out to a different server. The problem is that to run the data, I have to take one of the arguments and then run a report using it, which is very bash unfriendly (Ex. [3023.2<>1], [5111.3$]="5", etc).

So if I'm going to run the command, I need to put the argument in single quotes, which would then make the argument not be pulled into it.

Thus if I were to run the script...

arg1 = [5111.3$]="5"

runjob specfile.spx '$arg1'

This wouldn't work, but if I were to run it with double quotes, then there is a good chance that the argument that gets passed in will have double quotes. Any ideas on how to get around this?

A: 

Quote escapes. Try

[5111.3$]=\"5\"

The Advanced Scripting Guide has a good section on quoting.

Charlie Martin
+2  A: 

Use single quotes around the value when you set it, then use double-quotes around the variable when you expand it:

$ arg1='[5111.3$]="5"'
$ echo "$arg1"
[5111.3$]="5"
Eddie