I would like to play a short sound file from the command line in Mac OS X, independent of any audio player application, in order to provide notification that a long job has finished.

  • Possible duplicate: superuser.com/questions/969080/… ?
    – Coder
    Jun 28, 2022 at 23:16
  • @VikasGoel While I suppose that the terminal bell could count as “playing a short sound file”, it can't ever play a different sound file from the one configured as the system alert sound, so I would not count it as the same question.
    – Kevin Reid
    Jun 28, 2022 at 23:53

3 Answers 3


There is a built-in tool: afplay <sound file>. The man page does not document all of its options, which can be found via afplay -h:

afplay [option...] audio_file

Options: (may appear before or after arguments)
  {-v | --volume} VOLUME
    set the volume for playback of the file
  {-h | --help}
    print help
  { --leaks}
    run leaks analysis
  {-t | --time} TIME
    play for TIME seconds
  {-r | --rate} RATE
    play at playback rate
  {-q | --rQuality} QUALITY
    set the quality used for rate-scaled playback (default is 0 - low quality, 1 - high quality)
  {-d | --debug}
    debug print output

It will not play more than one audio file.

  • 1
    afplay sometimes has this bug: superuser.com/questions/319174/… . Are there any alternatives?
    – tog22
    Jan 13, 2015 at 12:48
  • Careful with the -v option: a value of 1 seems to mean "100%"!
    – doctaphred
    Apr 8, 2016 at 17:52
  • I discovered --volume or -v option is float as mentioned by @doctaphred. Don't use more than 1 if you have an external speaker Mar 16 at 8:24

One time, when the power went off at work, knowing that my firewall would return to that last state (powered on) when the electricty came back on, I wrote a script in bash that used the say command to wake me up when the power came back on.

  • 14
    I love abusing the say command.
    – NReilingh
    Jun 16, 2011 at 21:17
  • Indeed, say is relevant to this sort of problem and a good alternate solution. Have a vote! I was looking specifically for playing a short sound, though, as hearing a phrase would get tiresome for my use case.
    – Kevin Reid
    Jun 18, 2011 at 4:58
  • Interesting note: if you are remotely logged into a machine via ssh, say won't work unless you sudo it. (Much fun for making other people's computers talk to them.) Oct 29, 2016 at 17:59

Have you considered printf "\a\a\a" or echo -e "\a\a\a"?

  • 1
    For those that don't know this is the control sequence character for 'bell', which on most systems will make a 'bonking' sound
    – John Hunt
    Apr 19, 2018 at 14:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .