[SWLUG] whitespace, backslash,piping and quoting query

Dave Cridland [Home] dave at cridland.net
Sat May 3 20:41:09 UTC 2003


On Sat, 2003-05-03 at 17:02, bascule wrote:
> 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:)

While many of your problems are likely to stem from listening to Alison
Moyet ;-), the particular one in your mail is probably more to do with
shells only unescaping input supplied by the user, not from the output
of another program. 

There's probably hundreds of solutions, my personal fave would be:

(IFS="\
"; id3v2 -l `cat ~/Desktop/play2 | sed -e 's!\\\\ ! !g' -e 's!//!/!g'`)

I've done the "\ "=>" " translation in sed, because I have to, reading
from a file, unless I did a "read".

IFS is changed to a newline (escaped for the shell), and therefore I've
run this in a subshell to avoid pollution. (IFS is, I think, Input Field
Seperator).

The second sed thingy is there to compact the '//' into a '/', but this
is probably not required, since POSIX specifies that multiple
consecutive'/' are always treated as '/' except, possibly, for leading
'//'.

Someone else will no doubt improve on this.

Hope this helps - I don't have any MP3s about to test this with.

Dave.





More information about the Swlug mailing list