Stopping A Command-Line Loop

12 Sep
2015
12 Sep
'15
2:55 a.m.
I was playing a bunch of several dozen MP3 files in sequence using a command like for f in *.mp3; do ffplay -autoexit "$f"; done Then half-way through I decided to stop it. Trouble was, every time I hit CTRL/C, it killed the playback of the current MP3 file, but the loop just went on to the next one. Finally I hit CTRL/Z. This suspended the entire command, putting it in the background, and returned me to the command prompt. Then I was able to type kill %1 to kill the background job. In future, I will remember to use a command more like for f in *.mp3; do ffplay -autoexit "$f" || break; done This terminates the loop if the playback of a file aborts with an error.
3517
Age (days ago)
3517
Last active (days ago)
0 comments
1 participants
participants (1)
-
Lawrence D'Oliveiro