Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Emacs backup files start with .# but I can find those in my directory. I've try:

find . -name '^\.#.*'

or

find . -name '.*#.*'

and they are not show up, and I have them. For instance if I create one just for test:

touch '.#test'

and if I try to find it using find command it not show up.

share|improve this question

2 Answers 2

up vote 4 down vote accepted
> touch .#test
> find . -name '.#*'
./.#test

Works! find uses shell globbing, not regular expressions. . does not need to be escaped in the former because it is not a special character, it is always literal. The glob equivalent of the regexp wildcard . is ?. Also, * is a wildcard in globbing, the regexp equivalent of which is .* (* being a quantifier and not a wildcard in regexps).

share|improve this answer
    
Thanks, I thought that find use regex for -name. –  jcubic Feb 15 at 17:08
1  
@jcubic no, only for --regex. Please remember to accept this answer if it solved your issue. –  terdon Feb 15 at 18:09
    
@terdon You always need to wait (I think half an hour) before accepting. –  jcubic Feb 15 at 20:46
    
@terdon long options with double minus for find (--regex)? I think you fell victim to habitual typing ;-) –  Anthon Feb 16 at 10:06

This answer may work well.

find . -regex ".*\.#.*"
share|improve this answer

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.