I do not understand what you want to accomplish with this. Why do you need the quotes? You can add them inside your script if you really need it. Probably that's not the solution helping you best. Please clarify your problem/task.
Hi Stomp,
I'm in control of a built in script which i cant modify so am having to try find a working way of being able to change the command being run. As an example below, basically i want to be able to change the 'show log' command to a command that can be entered on command line.
Ah. Ok. I see. You think you need to use single quotes. But single quotes does not allow Variables-expansion inside.
You can just use double quotes. Should work like you want it:
MY_COMMAND="show full log"
Capture_log command="$MY_COMMAND" -o file='/home/user1/1.txt
The quotes are only there to keep the enclosed parameter in one piece. They are not delivered within the parameter. If the quotes are missing a parameter with spaces in it would be split up at those spaces(Not what you want). Thatswhy "...." and '...' can be exchanged here. The difference between the two is explained by your example: '...' protects from variables/subprocess/... expansion. "..." however allows this.
This still is far from clear. Is the line you cited not the command line? Please give way more context.
Just guessing: Do you want to read/assign something into a shell variable and use that instead of the show log , and it must be single quoted? Try double quoting the entire single quoted variable, as single quotes lose their meaning inside double quotes: