[SWLUG] whitespace, backslash,piping and quoting query

bascule asura at theexcession.co.uk
Sat May 3 16:02:49 UTC 2003


i have a something i can't explain, to illustrate i have pasted below, i'm aware that what appears can be be done differently but what i've pasted isn't what i'm trying to do, it illustrates my problem and i'd be grateful for a cogent explanation of what's going on:

[bascule at mycroft bascule]$ echo $(cat ~/Desktop/play2|sed 's/\/\//\//g'|tr "\n" " ")
/mp3s/Alison\ Moyet/Weak\ In\ The\ Prescence\ Of\ Beauty/01_Weak\ In\ The\ Presence\ of\ Beauty.mp3 /mp3s/Alison\ Moyet/Weak\ In\ The\ Prescence\ Of\ Beauty/02_Ordinary\ Girl.mp3
[bascule at mycroft bascule]$ id3v2 -l $(cat ~/Desktop/play2|sed 's/\/\//\//g'|tr "\n" " ")
fopen: /mp3s/Alison\: No such file or directory
/mp3s/Alison\: No ID3 tag
fopen: Moyet/Weak\: No such file or directory
Moyet/Weak\: No ID3 tag

as i understand it the first command takes the file ~Desktop/play2 which looks like:
/mp3s/Alison\ Moyet/Weak\ In\ The\ Prescence\ Of\ Beauty//01_Weak\ In\ The\ Presence\ of\ Beauty.mp3
/mp3s/Alison\ Moyet/Weak\ In\ The\ Prescence\ Of\ Beauty//02_Ordinary\ Girl.mp3
and replaces the double slash for a single slash and removes the newline leaving both filenames on the one line seperated a whitespace and echos this to the screen;

the second command, instead of echoing to the screen substitutes the result fro the arguments to 'id3v2 -l' which i was expecting to result in the display of the tags for the two files which exist on my system, clearly they don't, even though, if i manually type:
[bascule at mycroft bascule]$ id3v2 -l /mp3s/Alison\ Moyet/Weak\ In\ The\ Prescence\ Of\ Beauty/01_Weak\ In\ The\ Presence\ of\ Beauty.mp3 /mp3s/Alison\ Moyet/Weak\ In\ The\ Prescence\ Of\ Beauty/02_Ordinary\ Girl.mp3
i get the tags for both files, whereas above the command (and any other command i use in its place) seems to ignore the '\'s as escaping the whitespace in the filenames and use the whitespace to spilt the entire string into many sections, hence '/mp3s/Alison\: No such file or directory'

why does this happen? and how can i modify the above commands to work? - assume i'm not interested in a differnt approach for now:)

bascule

--
"Actors," said Granny, witheringly. "As if the world weren't full
of enough history without inventing more."
(Wyrd Sisters)





More information about the Swlug mailing list