What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again.

Delete that bloated snippets file you've been using and share your personal repository with the world. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Get involved!

You can sign-in using OpenID credentials, or register a traditional username and password.

First-time OpenID users will be automatically assigned a username which can be changed after signing in.

UpGuard checks and validates configurations for every major OS, network device, and cloud provider.

Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for:



May 19, 2015 - A Look At The New Commandlinefu
I've put together a short writeup on what kind of newness you can expect from the next iteration of clfu. Check it out here.
March 2, 2015 - New Management
I'm Jon, I'll be maintaining and improving clfu. Thanks to David for building such a great resource!

Top Tags



Psst. Open beta.

Wow, didn't really expect you to read this far down. The latest iteration of the site is in open beta. It's a gentle open beta-- not in prime-time just yet. It's being hosted over at UpGuard (link) and you are more than welcome to give it a shot. Couple things:

  • » The open beta is running a copy of the database that will not carry over to the final version. Don't post anything you don't mind losing.
  • » If you wish to use your user account, you will probably need to reset your password.
Your feedback is appreciated via the form on the beta page. Thanks! -Jon & CLFU Team

Commands tagged audio from sorted by
Terminal - Commands tagged audio - 55 results
soxi -D * | awk '{SUM += $1} END { printf "%d:%d:%d\n",SUM/3600,SUM%3600/60,SUM%60}'
for f in */*.ape; do avconv -i "$f" "${f%.ape}.flac"; done
2014-10-10 12:33:00
User: qdrizh

Converts all monkey audio files below currently directory to FLAC.

For only current directory, use `for f in *.ape; do avconv -i "$f" "${f%.ape}.flac"; done`

To remove APE files afterward, use `rm */*.ape`

find . -name '*.mp3' | sort | while read -r mp3; do echo -e "<h3>$mp3</h3>\n<audio controls src=\"$mp3\"></audio>"; done > index.html; python -m http.server
2014-03-24 15:01:49
User: hendry
Functions: echo find python read sort
Tags: audio browser

I tried a few curses based mp3 players for playing back choir practice songs for my wife.

Unfortunately none of the ones I tried were capable of scrubbing a track.

Firefox saves the day.

shnsplit -t "%n-%t" -f <cue file> <audio file>
say () { mpv $(sed -E "s;([a-Z]*)( |$);http://ssl.gstatic.com/dictionary/static/sounds/de/0/\1.mp3 ;g" <<< $*); }; say hello world "how is it" going
amixer -c 0 set Master 1dB+
2013-07-25 15:28:45
User: chrisp6825
Functions: amixer set

adjusts the 'Master' channel's volume up by 1dB.

Can use command 'amixer' to see other channels :

Simple mixer control 'Master',0


Simple mixer control 'Capture',0

for i in *.VOB; do mplayer "$i" -ao pcm:file="${i%.*}.wav"; done
for i in *.wav; do sox "$i" "${i%.*}_RightChan.wav" remix 2; done
ffmpeg -loop 1 -i image.png -i sound.mp3 -shortest video.mp4
pronounce(){ xidel "http://www.m-w.com/dictionary/$*" -f "replace(css('.au')[1][email protected],\".*'([^']+)', *'([^']+)'.*\", '/audio.php?file=\$1&word=\$2')" -f 'css("embed")[1][email protected]' --download - | aplay -q;}
2013-04-18 13:03:16
User: BeniBela
Functions: aplay

Updated to the new version of the MW webpage (seems MW does not use cougar anymore, so the other commands do not work nowadays), and using Xidel to parse the page with a html parser instead regex.

Example usage:

pronounce onomatopoetic

I'm not sure how well Xidel works with binary streams (although it seems to work great in tests), so using wget to download the actual wav file might be safer, i.e.:

pronounce(){ wget -qO- $(xidel "http://www.m-w.com/dictionary/$*" -f "replace(css('.au')[1][email protected],\".*'([^']+)', *'([^']+)'.*\", '/audio.php?file=\$1&word=\$2')" -e 'css("embed")[1][email protected]') | aplay -q;}

Xidel is not a standard cli tool and has to be downloaded from xidel.sourceforge.net

amixer -c 0 set Master 100%
2013-03-28 16:30:10
User: thewarden
Functions: amixer set

Replace "Master" with desired control name (e.g. Front, Earphone, PCM, etc.).

echo "aplay ring.wav" | at now + 25 min
2013-03-22 04:27:57
User: liancheng
Functions: at echo

The Pomodoro Technique is a time management method developed by Francesco Cirillo in the late 1980s. The technique uses a timer to break down periods of work into 25-minute intervals called 'Pomodori' (from the Italian word for 'tomatoes') separated by short breaks.

You need to prepare a short .wav file (the "ring.wav" in the sample command line). This command will trigger aplay to play ring.wav 25 minutes from now on, which can be used as a poor man's pomodoro timer.

sox -d -p | ffmpeg -i pipe:0 -f flv -preset ultrafast -tune zerolatency rtmp://localhost/live/livestream
2013-02-20 12:04:49
User: adimania

sox (SOund eXchange) can capture the system audio be it a browser playing youtube or from hardware mic and can pipe it to ffmpeg which encodes it into flv and send it over rtmp.

Tested using Red5 rtmp server.

ffmpeg -i source.mpg -f s16le -acodec pcm_s16le audio.raw
2013-01-10 02:54:04
User: manuq

-i sets the source file

-f and -acodec both set the output to be raw audio, PCM signed 16-bit little endian

find /path/to/dir -iname "*.ext" -print0 | xargs -0 mplayer -really-quiet -cache 64 -vo dummy -ao dummy -identify 2>/dev/null | awk '/ID_LENGTH/{gsub(/ID_LENGTH=/,"")}{SUM += $1}END{ printf "%02d:%02d:%02d\n",SUM/3600,SUM%3600/60,SUM%60}'
2012-03-11 12:28:48
User: DarkSniper
Functions: awk find printf xargs

Improvement on Coderjoe's Solution. Gets rid of grep and cut (and implements them in awk) and specifies some different mplayer options that speed things up a bit.

for ((x=0;;x+=5)); do sleep 5; hours=$(($x/3600)); minutes=$(($x%3600/60)); seconds=$(($x%60)); echo "$hours hours $minutes minutes $seconds seconds have elapsed" | festival --tts & done
2012-03-06 22:58:43
User: mrklaw
Functions: echo sleep

Says time every 5 seconds in hours, minutes and seconds using festival.

for ((x=0;;x+=5)); do sleep 5; echo $x | festival --tts & done
2012-03-06 21:17:51
User: mrklaw
Functions: echo sleep

works the same, but uses festival instead of espeak

ffmpeg -i video.flv audio.ogg
2012-03-05 23:43:45
User: aminehmida

A simple command to extract audio from flv/mp4 video file.

Just change extentions...

for ((x=0;;x+=5)); do sleep 5; espeak $x & done
2012-02-22 00:26:57
User: adeverteuil
Functions: sleep
Tags: audio bash timer

Useful contexts :

You are doing yoga or some other physical training in which you are holding a position.

Or you practice the pomodoro productivity technique.

Or your girlfriend said "We're leaving in 40 minutes".

Design details:

sleep executes before espeak to give you a 5 seconds head start.

espeak is run in the background so it doesn't mess up the timing.

lame -m j -V 4 -q 0 --lowpass 17 -b 128 --cbr "infile" "128/outfile"
2011-12-22 04:49:22

This converts a mp3 file "infile" to a CBR 128 kbps high quality (according to Winamp) mp3 "128/outfile", joint-stereo, using LAME.

mplayer -endpos 0.1 -vo null -ao null -identify *.avi 2>&1 |grep ID_LENGTH |cut -d = -f 2|awk '{SUM += $1} END { printf "%d:%d:%d\n",SUM/3600,SUM%3600/60,SUM%60}'
for x in 8svx aif aifc aiff aiffc ... wv wve xa xi ; do echo $x ; play -q -t $x soundfile trim 0 3 ; done
2011-12-09 00:23:45
Functions: echo

I wasted two hours reading the sox documentation and searching on the web for the format of some obscure fscking sound sample, and then finally came up with this. This plays only the first three seconds of your unknown formatted sound file using every one of sox's built-in filetypes. If you don't get an exact match, you may get close.


I could not fit every single type in and keep it under 127 characters, so you will have to replace "..." with the full list obtainable by `$ sox --help` (or try `Show sample output`)


note: /usr/bin/play should be linked to sox on most systems.

play -c 2 -n synth pinknoise band -n 2500 4000 tremolo 0.03 5 reverb 20 gain -l 6
2011-11-19 22:40:42
User: lordtoran
Tags: audio sox noise

This generates some powerful but relatively unobtrusive waterfall-like noise. Good if you need to get serious stuff done while your next-door neighbor is throwing a very loud party.

You need the sox package installed.

sox -t alsa default ./recording.flac silence 1 0.1 5% 1 1.0 5%
2011-03-08 14:36:39
User: sairon

Records audio from your mic in FLAC (Free Lossless Audio Codec) format, starts only after it detects at least 0.1 seconds of noise and stops after 1 second of silence. You can adjust the percent values (sensitivity) to best fit your microphone and voice (0.1% if you have a great quality mic, higher if you don't, 0% does not trim anything).

Useful for speech recognition in conjunction with my previous command titled 'Google voice recognition "API"' (http://www.commandlinefu.com/commands/view/8043/google-voice-recognition-api).

wget -q -U "Mozilla/5.0" --post-file speech.flac --header="Content-Type: audio/x-flac; rate=16000" -O - "http://www.google.com/speech-api/v1/recognize?lang=en-us&client=chromium"
2011-03-08 13:39:01
User: sairon
Functions: wget

The FLAC audio must be encoded at 16000Hz sampling rate (SoX is your friend).

Outputs a short JSON string, the actual speech is in the hypotheses->utterance, the accuracy is stored in hypotheses->confidence (ranging from 0 to 1).

Google also accepts audio in some special speex format (audio/x-speex-with-header-byte), which is much smaller in comparison with losless FLAC, but I haven't been able to encode such a sample.