Hello, everybody... I'm suffering a huge problem with the "for" command
because it wants to parse a variable ignoring escape characters.
For example, as you know, if I do something like this in bash:
for i in sony apple "hewlett packard"
do
echo $i
done
It will echo the following:
sony
apple
hewlett packard
However, I have a program that generates a list of files (let's say like the
previous one) that I want to use. This is what I get when some file names
have spaces:
for i in `my-program`
do
echo $i
done
It echoes the following:
sony
apple
hewlett
packard
Did you notice how it broke "hewlett packard" in two separate strings? That
is, it uses the spaces to parse the file names!
I changed my program to add quotes, something like the following:
"sony"
"apple"
"hewlett packard"
Now the same snippet of code generates the following:
"sony"
"apple"
"hewlett
packard"
That is, it ignores the quotes! I also tried using \ to escape the spaces,
and I got something like the following:
sony
apple
hewlett\
packard
Any ideas?
Thanks a bunch!
Luis
--
View this message in context:
http://www.nabble.com/for-...-in-...-do-ignores-escape-characters-tp16753925p16753925.html
Sent from the Gnu - Bash mailing list archive at Nabble.com.