Is there a way to make ${VAR}
expand as if it were quoted in double quotes?
That's not what I wanted to see:
% A="some spaces in there"
% touch ${A}
% ls -1
in
some
spaces
there
Sure, I can use typical notation like "$VAR"
. But that's cumbersome when using quotes within quoted text, etc. I wonder if there's a way of expanding ${...} notation that would treat ${...}
as if it were "${...}"
while not using doublequotes themselves?
You can set the IFS variable to disregard spaces when the shell splits variables. This is also useful when taking in input that may contain spaces in loops.
(If you have characters like * in your strings try a set -f to disable globbing (see help set) thanks @glenn jackman. But really, putting a * in a filename is asking for trouble!)
And the original: