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 libdave from sorted by
Terminal - Commands by libdave - 6 results
\ls
2012-01-05 00:35:49
User: libdave
5

say, someone has aliased ls to 'ls --color=always' and you want to temporarily override the alias (it does not override functions)

function eve (); { eval "print -s ${1?no variable}=\'\$$1\'" }
2012-01-03 17:03:00
User: libdave
Functions: eval
2

This only makes sense if you are using command line editing.

Create the function in your current zsh session, then type

eve PATH

go 'UP' in your history and notice the current (editable) definition of PATH shows up as the previous

command.

Same as doing:

PATH="'$PATH'"

but takes fewer characters and you don't have to remember the escaping.

grep -Ir foo *
2009-07-17 15:30:10
User: libdave
Functions: grep
0

short command to find a string in all text files in all subdirectories, excluding all files grep does not deem text files.

file =top
2009-07-15 21:29:23
User: libdave
Functions: file
4

Say you want to execute 'file' on the command 'top' (to determine what type of file it is); but you don't know where 'top' resides: preface the argument with = and zsh will implicitly prepend the path.

print -s "PATH='$PATH'"
2009-07-15 16:38:23
User: libdave
0

say you want to edit your PATH variable using bash/zsh commandline editing, this will put something like this in history so you can edit it:

PATH=/bin:/usr/bin:/usr/sbin

to make this a shell function such that:

eev HOME

will put /home/dave in the last history event:

eev()

{

print -s "$1='$(eval echo \$$1)'"

}

vi `!!`
2009-07-15 15:20:58
User: libdave
Functions: vi
0

say you've just found all the config files with this command

find . -name '*.config'

and you need to edit them all

vi `!!`

will re-execute the command and present them to vi in the argument list

don't use if the list is really long as it may overflow the command buffer