Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

hide output of aplay shell command

Is there a way to hide the output of the aplay command when play a sound?

I tried this without success

$ aplay ~/.zsh/sounds/done.wav >> /dev/null

Playing WAVE '/home/oscar/.zsh/sounds/done.wav' : Unsigned 8 bit, Rate 11025 Hz, Mono

I'll appreciate your help.

like image 923
oskargicast Avatar asked Jun 09 '14 18:06

oskargicast


People also ask

How do you suppress command output?

Silencing Output To silence the output of a command, we redirect either stdout or stderr — or both — to /dev/null. To select which stream to redirect, we need to provide the FD number to the redirection operator.

How do I turn off output in bash?

If you are looking to suppress or hide all the output of a bash shell script from Linux command line as well as from the crontab then you can simply redirect all the output to a file known as /dev/null . This file is known as Black Hole which will engulf everything you give without complaining.

How do I run a script without output?

Use nohup if your background job takes a long time to finish or you just use SecureCRT or something like it login the server. Redirect the stdout and stderr to /dev/null to ignore the output. Just to add, sometimes there are arguments for the scripts then above command will return Ambiguous output redirect.

What does aplay do?

aplay is a command-line audio player for ALSA(Advanced Linux Sound Architecture) sound card drivers. It supports several file formats and multiple soundcards with multiple devices. It is basically used to play audio on command-line interface. aplay is much the same as arecord only it plays instead of recording.


1 Answers

Simply add the -q option:

aplay -q ~/.zsh/sounds/done.wav

No need to redirect stdout to /dev/null there.

Another note: aplay actuall sends messages to /dev/stderr (fd 2). You can also nullify the output by sending it to /dev/null:

aplay ~/.zsh/sounds/done.wav 2>/dev/null

You can see more options with aplay --help. This line is about -q:

-q, --quiet             quiet mode
like image 100
konsolebox Avatar answered Oct 19 '22 06:10

konsolebox