31

I'm using some Bash scripts under Linux that require some time to complete; I'd like to add at the end of them a command to ring the system bell when those tasks are done, so I can be notified.

What's the proper command to do that? (please note that what I need is to be notified, with a sound and possibly with a message, so I can accept any solution in these regards).

9
  • 7
    Downvoting without an explanation is not very useful... – Sekhemty Sep 6 '15 at 14:19
  • 1
    These solutions aren't working for me. – Sekhemty Sep 6 '15 at 14:27
  • 4
    What does your research tell you? What exactly have you tried and what didn't work? – slhck Sep 6 '15 at 14:41
  • 1
    ( speaker-test -t sine -f 440 )& pid=$! ; sleep 0.4s ; kill -9 $pid requires ALSA installed. Always from one of that answers – Hastur Sep 8 '15 at 13:20
37
tput bel

is a relatively portable solution.

3
  • "tput bel" works on macOS, as it should. – John Dallman Dec 14 '17 at 15:46
  • Works on Cygwin bash terminal as well. – ysap Aug 10 '18 at 17:25
  • Works on CentOS 7 bash via macOS terminal. – rinogo Sep 3 '20 at 14:59
14

Try this command:

echo -e "\07"
2
  • 1
    N.B. The -e is needed to enable interpretation of the \07 escape sequence. – FKEinternet Nov 27 '17 at 11:20
  • Works on Cygwin bash terminal as well. – ysap Aug 10 '18 at 17:25

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