Reputation: 4968
I have this code
for p in "abra/cadabra reach/out"
do
r="$HOME/x/$p"
echo $r
done
But it only produces this:
/Users/terrencemonroebrannon/x/abra/cadabra reach/out
Not
/Users/terrencemonroebrannon/x/abra/cadabra /Users/terrencemonroebrannon/x/reach/out
as I would expect.
Upvotes: 1
Views: 77
Reputation: 311516
You have placed your two items in quotes, which bash interprets as a single token. That's what quotes are for. You would get the behavior you describe if you were to remove the quotes:
for p in abra/cadabra reach/out
do
r="$HOME/x/$p"
echo $r
done
Gives me:
/Users/lars/x/abra/cadabra
/Users/lars/x/reach/out
Upvotes: 5
Reputation: 161654
bash will see "abra/cadabra reach/out"
as one token.
Quotes are not needed.
for p in abra/cadabra reach/out
do
r="$HOME/x/$p"
echo $r
done
Upvotes: 2