Play MP3′s and other music from the command line
Ever wanted to play music while you’re working in the command line? With the command line tool ‘afplay’ you can do just that, you can play practically any audio file from the Terminal, just type:
You can then stop it with Control-C, otherwise the song will play itself through then terminate. If you’d rather afplay run in the background while playing audio, use this command:
afplay /path/to/audiofile.mp3 &
This launches afplay into the background, if you want to shut it up you can just kill the process with:
Not that I’m condoning this type of behavior, but I recently used the afplay command to play a pretty amusing prank on a coworker by SSHing into his work machine and forcing him to listen to a Miley Cyrus song, he didn’t figure out what was going on until it was over and I told him.