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.

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:



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.

Top Tags



Find all dot files and directories

Terminal - Find all dot files and directories
ls -a | egrep "^\.\w"
2009-11-11 18:19:56
User: kulor
Functions: egrep ls
Find all dot files and directories

trying to copy all your dotfiles from one location to another, this may help


There are 2 alternatives - vote for the best!

Terminal - Alternatives
echo .*
ls -d .*
printf "%s\n" .*
printf "%s\n" .*
2009-11-23 18:07:18
User: cfajohnson
Functions: printf
Tags: dotfiles

In most modern shells, printf is a builtin command.

Know a better way?

If you can do better, submit your command here.

What others think

This is possible with 'find', but is quite verbose:

find -maxdepth 1 -regex '^\./\..*' -printf '%f\n' | sort

piping through 'sort' to match default output of 'ls'.

Comment by pysquared 284 weeks and 2 days ago

If the goal of "\w" in the regexp is to avoid listing . and .. then ls has the -A option.

Comment by rbossy 284 weeks and 2 days ago
ls -1d .*

no need grep here...

Or simply $ ls .[tab]

Comment by sputnick 284 weeks and 2 days ago

@pysquared considered find but as you mentioned, it is a bit to verbose.

@rbossy the goal of the \w is to filter the results to return only dotfiles and folders but exclude '.' & '..' at the same time.

The following code does not work in the context of searching dotfiles

'ls -aA .*'


ls -1d .*



So I would still need to inverse grep the results anyway

Comment by kulor 284 weeks and 2 days ago
ls -1d .[[:alnum:]]*
Comment by sputnick 284 weeks and 2 days ago

@sputnick nice one

Comment by kulor 284 weeks and 2 days ago

@kulor: c'mon, if you use -A instead of -a, the \w in the regexp is useless.

@sputnik: I think it does not exclude . and ..

Comment by rbossy 284 weeks and 1 day ago

@pysquared: -name ".*". No need regex.

Comment by unixmonkey7109 283 weeks ago

@unixmonkey7109: I tried -name ".*", but it does not exclude ".".

Comment by pysquared 283 weeks ago

Your point of view

You must be signed in to comment.