Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a playlist, m3u extended, formated like:

#EXTINF:213,2 Tåst - (foo bar) 
/home/www/Music/Test/test 123 - test.mp3

My problem is, that it seems the line-break is encoded as '\n\r' which makes looping over the file kind of hard:

sed '/\.mp3/s/\.mp3.*/.mp3/' test.m3u | while read line ; do cp "$line" "test/" ; done

There're also some flacs, but that's another issue... The problem with this is as follows:

cp: cannot stat `#EXTINF:125,5 /home/www/Music/Test/test 123 - test.mp3\r': No such file or directory

My two issues are: the first "`" and the terminating character '\r' are misplaced. Is there any better way to pase this in ZSH/Bash so that I can copy my playlist to my Android?

Best, www

share|improve this question

I'd use grep and tr instead:

grep -v '#' test.m3u | tr -d '\r' | while read line ; do cp "$line" "test/" ; done

This'll work on all files in the playlist since everything except file names and paths begins with # in a .m3u-file.

Edit: The sed way to do this is:

sed -e 's/.$//;/#/d' test.m3u |while read line ; do cp "$line" "test/" ; done

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.