Am Fre, 2003-10-17 um 18.54 schrieb LeVA: > Hello! > > I wanted to create a tiny script which reads a .m3u file, and then > copies the "real" mp3 files which has an entry in the m3u file to a > given dir. > > Here is my idea: > > ---------- # Script # ---------- > #!/bin/bash > TMP=/tmp/cpm3u_tmp > cat "$1" | grep -v --regexp="#" > $TMP > for line in $(<$TMP); do > echo "$line"; > done > ---------- # Script # ---------- > > A problem occurs, when there is a .m3u file, which has entries with > spaces in their names, like this: > > ---------- # m3u file # ---------- > #EXTM3U > #EXTINF:278,Republic - Igen - Hozd El Azt A Napot > /home/leva/Zene/Republic/1996 Igen/02. Hozd El Azt A Napot.mp3 > ---------- # m3u file # ---------- > > I get an output like this: > > ---------- # Output # ---------- > /home/leva/Zene/Republic/1996 > Igen/02. > Hozd > El > Azt > A > Napot.mp3 > ---------- # Output # ----------
The for-loop uses the IFS (Internal Field Separator -> man bash) to separate its arguments. The default IFS includes SPACE, TAB, NEWLINE and maybe more. In your case you want IFS to be set to NEWLINE (and *only* to NEWLINE). You can do it like this: IFS=" " Maybe there is a more elegant solution to set IFS to NEWLINE. HTH -- Matthias Hentges Cologne / Germany [www.hentges.net] -> PGP welcome, HTML tolerated ICQ: 97 26 97 4 -> No files, no URL's My OS: Debian Woody. Geek by Nature, Linux by Choice
signature.asc
Description: Dies ist ein digital signierter Nachrichtenteil