Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I want to find all dot directory in home directory

 find  ~/ -name .*    -Olevel 1

But it can not work

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

The problem is that your shell is expanding .*. You want to quote it instead, i.e. '.*', so that find deals with it instead of your shell.

For example, to find all directories in your home directory,

find ~ -maxdepth 1 -type d -name '.*'

on my system, this produces:

/root/.config
/root/.java
/root/.cache
/root/.aptitude
/root/.gnupg
/root/.grails
/root/.dbus
/root/.ssh
share|improve this answer
    
Thanks , there is warning "find: warning: you have specified the -maxdepth option after a non-option argument -type, but options are not positional (-maxdepth affects tests specified before it as well as those specified after it). Please specify options before other arguments." –  larry May 29 '12 at 6:49
    
You probably have a different version of find than I do, as I don't receive that error. I've amended my post—it should work now. –  Chris Kuehl May 29 '12 at 7:41
add comment

You can use

find ~/ -maxdepth 1 -name '.*' -type -d 

You have to stop the shell from expanding the .* by putting ' around it then find then expands '.*' correctly. To find only directories use the -d switch and to limit find to the ~/ directory use -maxdepth 1.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.