bash: how ls content of a variable in bash script
I have a variable containing various file and directory paths, thus:
Code:
echo $brn Code:
ls "/home/g/ToBurn/Fugitives (1986) Les fugitifs" "/home/g/ToBurn/Kosmos-[2010]-DVDRIP-[TUR]-Hitro" "/home/g/ToBurn/Night.on.Bald.Mountain.avi" "/home/g/ToBurn/Riget II/R2E2" "/home/g/ToBurn/Riget II/R2E4" "/home/g/ToBurn/Riget II/R2E1" "/home/g/ToBurn/Riget1/R1E3" "/home/g/ToBurn/Riget1/R1E2" |
Hi,
try it this way: Code:
var="'dir' 'Liszt - Piano Concertos 1 & 2'" You can also use the quotes "the other way around" Code:
var='"dir" "Liszt - Piano Concertos 1 & 2"' |
I am not sure I understand the issue? How is the output you have shown wrong or could you maybe show what you are expecting?
|
Quote:
|
Quote:
Code:
ls $brn I've so far not been able to figure out a reliable rule to predict how bash will deliver the content of a variable. Mostly, it does as expected, sometimes, like this example, it doesn't. But it does seem to be generally true that if such content is not delivered as expected, then eval will fix it for you. |
ahhh ... with you now :) Sorry had my blinkers on when reading this one.
|
I'd like to know what you're actually trying to do with the script. Pretty much all uses of "eval" are better done using some other method. Also attempting to do anything with ls besides display to the user is rife with problems.
|
All times are GMT -5. The time now is 03:11 AM. |