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



Commands tagged sox from sorted by
Terminal - Commands tagged sox - 12 results
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.

paste <(seq 7 | shuf | tr 1-7 A-G) <(seq 7 | shuf) | while read i j; do play -qn synth 1 pluck $i synth 1 pluck mix $2; done
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 input.mp3 output.mp3 fade h 5 00:02:58 5
2011-09-03 13:59:03
User: kev
Tags: sox

fade [type] fade-in-length [stop-time [fade-out-length]]

Apply a fade effect to the beginning, end, or both of the audio.

An optional type can be specified to select the shape of the fade curve: q for quarter of a sine wave, h for

half a sine wave, t for linear (`triangular') slope, l for logarithmic, and p for inverted parabola. The

default is logarithmic.

A fade-in starts from the first sample and ramps the signal level from 0 to full volume over fade-in-length sec?

onds. Specify 0 seconds if no fade-in is wanted.

For fade-outs, the audio will be truncated at stop-time and the signal level will be ramped from full volume

down to 0 starting at fade-out-length seconds before the stop-time. If fade-out-length is not specified, it

defaults to the same value as fade-in-length. No fade-out is performed if stop-time is not specified. If the

file length can be determined from the input file header and length-changing effects are not in effect, then 0

may be specified for stop-time to indicate the usual case of a fade-out that ends at the end of the input audio


All times can be specified in either periods of time or sample counts. To specify time periods use the format

hh:mm:ss.frac format. To specify using sample counts, specify the number of samples and append the letter `s'

to the sample count (for example `8000s').

rec -c 2 -r 44100 -s -t wav - | flac - --sign=signed --channels=2 --endian=big --sample-rate=44100 --bps=16 -f -o file.flac
2011-08-30 03:14:32
User: bohwaz

You'll need to install sox and flac packages in Debian/Ubuntu.

/usr/bin/play -q -n synth brown band -n 1200 200 tremolo 0.05 80
2011-04-26 19:37:08
User: Mozai
Tags: sound sox noise

Substitute 'brown' with 'pink' or 'white' according to your taste.

I put this on my headphones when I'm working in an "open concept" office, where there are always three to five conversations going in earshot, or if I'm working somewhere it is "rude" of me to tell a person to turn off their cubicle radio.

file /music/dir/* | grep -v 44.1 | sed 's/:.*//g' | grep .mp3 | { while IFS= read; do filebak="\"$REPLY.original\""; file="\"$REPLY\""; mv $file $filebak; sox -t mp3 $filebak $file rate 44k; done; };
2010-08-12 21:53:28
User: IgnitionWeb
Functions: file grep mv sed
Tags: mp3 sox resample

This heavy one liner gets all the files in the "/music/dir/" directory and filters for non 44.1 mp3 files. After doing this it passes the names to sox in-order to re-sample those files. The original files are left just in case.

sox Klaxon.mp3 -t wav - |ssh [email protected] paplay
2010-07-29 23:23:39
User: camocrazed
Functions: ssh

This will allow you to convert an audio file to wav format, and send it via ssh to a player on the other computer, which will open and play it there. Of course, substitute your information for the sound file and remote address

You do not have to use paplay on the remote end, as it is a PulseAudio thing. If the remote end uses ALSA, you should use aplay instead. If it uses OSS, you should berate them about having a lousy sound system. Also, you're not limited to transmitting encoded as wav either, it's just that AFAIK, most systems don't come with mp3 codecs, but will play wav files fine.

If you know SoX is installed on the remote end and has mp3 codecs, you can use the following instead:

cat Klaxon.mp3 |ssh [email protected] play -t mp3 -

this will transmit as mp3. Again, use your specific information. if you're not playing mp3s, use another type with the -t option

sox *.mp3 -t wavpcm - | lame - > bunch.mp3
2010-01-20 01:27:12
User: sputnick
Tags: lame sox

That way, you can make a mix on the fly with the mp3 files in the current directory to make a bunch mp3 file.

for n in E2 A2 D3 G3 B3 E4;do play -n synth 4 pluck $n repeat 2;done
2009-12-13 06:57:26
User: eightmillion

This command, taken from play's manual page, plays a synthesized guitar tone for each of the strings on a standard tuned guitar.

The command "play" is a part of the package "sox".

(echo CD_DA; for f in {01..99}; do echo "$f Hz">&2; sox -nt cdda -r44100 -c2 $f.cdda synth 30 sine $f; echo TRACK AUDIO; echo FILE \"$f.cdda\" 0; done) > cdrdao.toc && cdrdao write cdrdao.toc && rm ??.cdda cdrdao.toc
2009-11-17 06:23:42
User: hackerb9
Functions: cdrdao echo rm write

This command creates and burns a gapless audio CD with 99 tracks. Each track is a 30 second sine wave, the first is 1 Hz, the second 2 Hz, and so on, up to 99 Hz. This is useful for testing audio systems (how low can your bass go?) and for creating the constant vibrations needed to make non-Newtonian fluids (like cornstarch and water) crawl around.

Note, this temporarily creates 500MB of .cdda files in the current directory. If you don't use the "rm" at the end of the command, you can burn more disks using

cdrdao write cdrdao.toc

Prerequisites: a blank CD-R in /dev/cdrw, sox (http://sox.sourceforge.net/), and cdrdao (http://cdrdao.sourceforge.net/). I'm also assuming a recent version of bash for the brace expansion (which just looks nicer than using seq(1), but isn't necessary).