views:

16

answers:

2

Hi

I'm trying to find all long filenames in a directory using:

find . -regex './[^/]\{5,\}.txt' 

According to the GNU find documentation, -regex uses emacs regex by default. So this should give me all files longer than 5 characters (excluding extension). Unfortunately it does not work. It matches nothing. I've tried various variations on this theme but to no avail. Any ideas? Does GNU find simply not support the repetition qualifier?

Thanks

Pascal

+1  A: 

Add

-regextype posix-extended

and no need to escape { }

find . -regextype posix-extended -regex './[^/]{5,}.txt' 
codaddict
Remember that `.` is a regexp metacharacter, so this should be `-regex '\./[^/]{5,}\.txt'` (yes, the first `.` doesn't need a backslash in this particular case, but do you really want to ponder why each time you stare at the command?). And since you're not looking inside subdirectories, add `-maxdepth 1`, it will save a lot of time if there are a lot of subdirectories.
Gilles
+1  A: 

why so complicated?

find /path -type f -iname "??????*.txt"
ghostdog74
I don't want to have to count the characters... 5 is just an example. It should be much more and it can vary, so I want it to be easy to change.
Pascal