Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am trying to use tail -f and play a sound everytime a new line appears.

I tried this:

for i in tail -f myFile; do aplay alert.wav; done;

Which kinda worked, the output is:

Playing WAVE 'alert.wav' : Signed 16 bit Little Endian, Rate 22050 Hz, Mono
Playing WAVE 'alert.wav' : Signed 16 bit Little Endian, Rate 22050 Hz, Mono
Playing WAVE 'alert.wav' : Signed 16 bit Little Endian, Rate 22050 Hz, Mono

But after 3 times it stops, and I would like to print the tail -f result and not the aplay result.

How could I achieve that?

share|improve this question

1 Answer 1

up vote 2 down vote accepted

I'm not on a Linux right now, but it should work like this:

tail -f yourFile | while read line ; do aplay alert.wav 2>&1 1>/dev/null ; echo $line ; done

On Mac OS X, I'm using the following successfully to print the system log:

tail -f /private/var/log/system.log | while read line; do printf "\a" ; echo $line ; done
share|improve this answer
    
Thanks it does work, I added aplay -q so it wont show the aplay results. –  foralsa May 8 '11 at 18:51
    
@foralsa Thanks. Since I don't know anything about aplay I just redirected its output. Should also work. –  Daniel Beck May 8 '11 at 18:51

Your Answer

 
discard

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.