Hide

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.


If you have a new feature suggestion or find a bug, please get in touch via http://commandlinefu.uservoice.com/

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.

Universal configuration monitoring and system of record for IT.
Hide

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:

Hide

News

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!
Hide

Top Tags

Hide

Functions

Hide

Credits

All commands from sorted by
Terminal - All commands - 12,158 results
curl -s -d URL="$1" http://is.gd/create.php | sed '/Your new shortened/!d;s/.*value="\([^"]*\)".*/\1/'
2009-09-17 12:53:46
User: tatsu
Functions: sed
1

Just create a function in your .bashrc like this

shorturl() {

curl -s -d URL="$1" http://is.gd/create.php | sed '/Your new shortened/!d;s/.*value="\([^"]*\)".*/\1/'

}

echo "123.32.12.134" | grep -P '([01]?\d\d?|2[0-4]\d|25[0-5])\.([01]?\d\d?|2[0-4]\d|25[0-5])\.([01]?\d\d?|2[0-4]\d|25[0-5])\.([01]?\d\d?|2[0-4]\d|25[0-5])'
%s/@/^v[M]/g
2009-09-17 11:47:24
User: xraj
0

replace @ symbol with new line character, to get new line character press Ctrl+v+enter --> ^M

mplayer -fs -vf screenshot,mirror tv://
2009-09-17 05:15:42
User: kamathln
Tags: mplayer webcam
1

This directly puts the "mirror" into fullscreen, and lets you take photos by pressing the 's' key. I bet appearance conscious people will have keyboard shortcut for this command by now.

wajig large
mplayer tv:// -vf mirror
tar -cvf /dev/null . | while read i; do ls -l $i; done
2009-09-16 16:59:15
User: lbonanomi
Functions: ls read tar
-8

I find the ouput of ls -lR to be un-satisfying (why is the path data up there?) and find syntax to be awkward. Running 'du -a' means you will have likely to trim-off filesize data before feeding filenames to the next step in the pipe.

cvlc v4l2:// :vout-filter=transform :transform-type=vflip :v4l2-width=320 :v4l2-height=240 -f &
2009-09-16 15:30:52
User: Escher
2

Flips the y-axis to emulate a real mirror, uses low resolution for speed, this will also hide blemishes and the like :)

cvlc v4l2:// &
2009-09-16 14:52:36
User: Escher
1

Quick command to test your webcam. Press 'f' to toggle fullscreen. Can also use 'vlc v4l2://' if you want gui controls. For higher/smoother framerate lower the default resolution:

cvlc v4l2:// :v4l2-width=320 :v4l2-height=240 &
ffmpeg -f alsa -ac 2 -i hw:1,0 -acodec libmp3lame -ab 96k output.mp3
2009-09-16 12:45:44
User: ivalladt
4

Record audio to an MP3 file via ALSA. Adjust -i argument according to arecord -l output.

curl "http://api.bit.ly/shorten?version=2.0.1&longUrl=<LONG_URL_YOU_WANT_SHORTENED>&login=<YOUR_BITLY_USER_NAME>&apiKey=<YOUR_API_KEY>"
2009-09-16 11:36:25
User: rungss
2

Shorten any Url using bit.ly API, using your API Key which enables you to Track Clicks

I have it as a Function in my .bash_aliases

[code]

shorten ()

{

longUrl=$1;

curl "

}

[/code]

Here is an Output showing the Function Detail..

[konsole]

bijay@bijay:$ type shorten

shorten is a function

shorten ()

{

longUrl=$1;

curl "

}

[/konsole]

lsb_release -a
ls -lt|grep ^-|awk 'NR>5 { print $8 }'|xargs -r rm
ls -t | tail +6 | xargs rm
gst-launch-0.10 autovideosrc ! video/x-raw-yuv,framerate=\(fraction\)30/1,width=640,height=480 ! ffmpegcolorspace ! autovideosink
2009-09-16 06:31:23
User: jcollado
2

Open a window that displays camera capture.

Framerate, width and height may be changed to match your needs.

ps -u<user>
ls -t | awk 'NR>5 {system("rm \"" $0 "\"")}'
2009-09-16 04:58:08
User: haivu
Functions: awk ls
Tags: awk ls
-2

I have a directory containing log files. This command delete all but the 5 latest logs. Here is how it works:

* The ls -t command list all files with the latest ones at the top

* The awk's expression means: for those lines greater than 5, delete.

mate - `find . -name 'filename'`
budir=/tmp/bu.$$;for name in repMainPath/*/format;do dir=${name%/format};bufil=dumpPath/${dir##*/};svnadmin hotcopy --clean-logs $dir $budir;svnadmin dump --delta $budir>$bufil;rm -rf $budir;done
2009-09-16 01:34:48
User: arcege
Functions: dump
Tags: bash svn
2

Use of hotcopy for safety/stability of the backups.

git add -u
2009-09-16 00:13:14
User: donnoman
Tags: git
48

It deletes all removed files, updates what was modified, and adds new files.

wget http://twitter.com/help/test.json -q -O -
2009-09-15 23:22:26
User: ninadsp
Functions: wget
3

Returns a JSON object, by connecting to the 'test' endpoint of the Twitter API. Simplest way to check if you can connect to Twitter. Output also available in XML, use '/help/test.xml' for that

find repMainPath -maxdepth 1 -mindepth 1 -type d | while read dir; do echo processing $dir; sudo svnadmin dump --deltas $dir >dumpPath/`basename $dir`; done
2009-09-15 20:14:51
User: Marco
Functions: dump echo find read sudo
Tags: bash svn
2

This command dumps all SVN repositories inside of folder "repMainPath" (not recursively) to the folder "dumpPath", where one dump file will be created for each SVN repository.

(some_command 2>&1 1>&3 | tee /path/to/errorlog ) 3>&1 1>&2 | tee /path/to/stdoutlog
mencoder tv:// -tv driver=v4l2:width=800:height=600:device=/dev/video0:fps=30:outfmt=yuy2:forceaudio:alsa:adevice=hw.2,0 -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=1800 -ffourcc xvid -oac mp3lame -lameopts cbr=128 -o output.avi
2009-09-15 19:46:06
User: ivalladt
6

Record audio to MP3 stream and video to MPEG-4 stream from webcam to AVI file using mencoder. Gives floating point exception in some mencoder versions.

mplayer tv:// -tv driver=v4l2:width=640:height=480:device=/dev/video0:fps=30:outfmt=yuy2
2009-09-15 19:41:41
User: ivalladt
5

View webcam output using mplayer, with correct fps and outfmt settings according to my webcam model.