Tuesday, December 2, 2008

Find Dot Files

Sometimes I forget the name of a particular config file but know it's stored as a dot file in my home directory. The following one-liner will non-recursively display any regular file begining with a dot.

find . -maxdepth 1 -type f -name '.*'

Find does it again. ;-)

5 comments:

Zachary Tatlock said...
This comment has been removed by the author.
Kurt said...

ls -d .*

Travis Whitton said...

@Kurt

That's good for dirs, but I was looking for files in this case.

Greg Whitescarver said...

For quickness, I type:
.*<tab><tab>

...that expands directories as well, but beats the other methods on speed. In general, <tab><tab> is a great way to see what your wildcards will expand to.

Douglas said...

ls -d .*

Lists plain files and directories. The -d is "list directory entries instead of contents". If you really do want to see only the files, then sure, you need the find command. It's a lot of typing to avoid seeing the directory names, though.