Quote:
Originally Posted by
Phil3759
Thank you for the basic explanation. I know well about the the splitting at spaces for unquoted variables, but thought that single quoting stops this.
Single-quoting a > will not let the shell parse it later. The quotes cease to exist when the string is stored, they only tell the shell what to do with a string
right then, they don't change the meaning later. Using single quotes versus double quotes tells the shell whether to attempt anything like substituting variables right now and no other time.
Be it single or double quoted, if you force a string to contain actual quote, pipe, redirection, backtick, or dollar-sign characters, the shell will understand them to be
literal characters, not anything with meaning.
In other words, storing shell statements inside strings continues to be a poor idea no matter how you cut it. There is not a mysterious "right way" to do this that we are hiding from you. If you explained your intent we could probably show you a better way to accomplish the
result you want, but it would be done in a completely different manner.