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.

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

2011-03-12 - Confoo 2011 presentation
Slides are available from the commandlinefu presentation at Confoo 2011: http://presentations.codeinthehole.com/confoo2011/
2011-01-04 - Moderation now required for new commands
To try and put and end to the spamming, new commands require moderation before they will appear on the site.
2010-12-27 - Apologies for not banning the trolls sooner
Have been away from the interwebs over Christmas. Will be more vigilant henceforth.
2010-09-24 - OAuth and pagination problems fixed
Apologies for the delay in getting Twitter's OAuth supported. Annoying pagination gremlin also fixed.
Hide

Tags

Hide

Functions

Commands by axelabs from sorted by
Terminal - Commands by axelabs - 11 results
[ $V ] || : $((V++)) && echo $V
2012-06-15 16:48:03
User: axelabs
Functions: echo
2

I just found another use for the builtin ':' bash command. It increments counters for me in a loop if a certain condition is met...

: [arguments]

No effect; the command does nothing beyond expanding arguments and performing any specified redirections. A zero exit code is returned.

rsync -avz ~/src ~/des/
2012-06-01 15:08:12
User: axelabs
Functions: rsync
0

rsync will copy the source directory into destination and any subsequent run will synchronize only the changes from the source.

date -d '2011-12-15 05:47:09' +"epoch: %s or format: %Y/%m/%d"
egrep -i " connected|card detect|primary dev" /var/log/Xorg.0.log
2011-02-24 18:04:04
User: axelabs
Functions: egrep
Tags: video egrep xorg
-1

The above one liner can be used to determine what card/driver is Xorg currently using. For additional information, see http://goo.gl/mDnWu

echo "tee can split a pipe in two"|tee >(rev) >(tr ' ' '_')
2010-08-14 20:38:59
User: axelabs
Functions: echo tee tr
32

Tee can be used to split a pipe into multiple streams for one or more process to work it. You can add more " >()" for even more fun.

echo -e "swap=me\n1=2"|sed 's/\(.*\)=\(.*\)/\2=\1/g'
cat /dev/urandom|awk 'BEGIN{"tput cuu1" | getline CursorUp; "tput clear" | getline Clear; printf Clear}{num+=1;printf CursorUp; print num}'
2009-07-13 07:30:51
User: axelabs
Functions: awk cat printf
Tags: nawk awk clear tput
0

awk can clear the screen while displaying output. This is a handy way of seeing how many lines a tail -f has hit or see how many files find has found. On solaris, you may have to use 'nawk' and your machine needs 'tput'

awk 'BEGIN{srand()}{print rand(),$0}' SOMEFILE | sort -n | cut -d ' ' -f2-
2009-05-29 01:20:50
User: axelabs
Functions: awk cut sort
Tags: sort awk random
4

This appends a random number as a first filed of all lines in SOMEFILE then sorts by the first column and finally cuts of the random numbers.

/usr/proc/bin/pfiles $PID
2009-03-05 17:26:57
User: axelabs
4

Report fstat(2) and fcntl(2) information for all open files in each process.

echo Print text vertically|sed 's/\(.\)/\1\n/g'
whois cmd.fu;whois cmdfu.com|grep -i cmdfu
2009-02-19 08:57:50
User: axelabs
Functions: whois
-11

It would be nice if commandlinefu.com had a better domain name. Will they pick one of the above; We'll see.