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

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
-2
Find all dot files and directories

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

Alternatives

There is 1 alternative - 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
0

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 298 weeks and 1 day ago

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

Comment by rbossy 298 weeks and 1 day ago
ls -1d .*

no need grep here...

Or simply $ ls .[tab]

Comment by sputnick 298 weeks and 1 day 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 .*'

@sputnick

ls -1d .*

.

..

So I would still need to inverse grep the results anyway

Comment by kulor 298 weeks and 1 day ago
ls -1d .[[:alnum:]]*
Comment by sputnick 298 weeks and 1 day ago

@sputnick nice one

Comment by kulor 298 weeks and 1 day 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 298 weeks ago

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

Comment by unixmonkey7109 296 weeks and 6 days ago

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

Comment by pysquared 296 weeks and 6 days ago

Your point of view

You must be signed in to comment.