[SWLUG] whitespace, backslash,piping and quoting query

Dave Cridland [Home] dave at cridland.net
Sun May 4 13:38:28 UTC 2003


On Sun, 2003-05-04 at 01:35, bascule wrote:
> [bascule at mycroft bascule]$ (IFS="\
> "; id3v2 -l `cat ~/Desktop/play2 | sed -e 's!\\\\ ! !g' -e 's!//!/!g'`)
> fopen: /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: No such file or directory
> /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: No ID3 tag

Oh... Hang on, that's not what I was expecting at all... :-)

Oh, I see why, I'm escaping the newline... Stupid me. Take out the "\"
before the newline, and it should work. Sorry, obviously wasn't thinking
when I wrote that. Probably the effects of Alison Moyet, you see. ;-)

> > IFS is changed to a newline (escaped for the shell), and therefore I've

See? Why did I escape a newline? Makes it invisible to the shell, so
this was equivalent to setting IFS to the empty string - no word
splitting at all. Silly me.

And it's Internal Field Seperator, since I looked it up. It's used for
output as well.

Dave.





More information about the Swlug mailing list