LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (http://www.linuxquestions.org/questions/linux-general-1/)
-   -   Unexpected behaviour with the find command (http://www.linuxquestions.org/questions/linux-general-1/unexpected-behaviour-with-the-find-command-266792/)

dazdaz 12-15-2004 04:54 PM

Unexpected behaviour with the find command
 
Hello,

I thought that I understood the find command enough to use it, when today I came across a real strange problem with the search pattern.

We create 3 files to re-create the situation.

~> touch host059.ks host060.ks host061.ks

~> find . -name "host0[59-61]*"
./host059.ks

What is the problem with my find command ? It should of found 3 files.

I see that there is the -iregex flag to find, however so far I cannot figure this out, nor do I know if that flag is the correct way to sort those 3 files.

Thanks

sigsegv 12-15-2004 05:12 PM

host[56][901]*

XavierP 12-15-2004 05:31 PM

Moved: This thread is more suitable in Linux-General and has been moved accordingly to help your thread/question get the exposure it deserves.

amfoster 12-15-2004 09:50 PM

You are using a poor regular expression.

host0[59-61] was looking for a host0 followed by a 5 or a 9-6 followed by a 1. Since the ascii table order is 0-9, you can not search for a 9-6 range.

host* would have worked, or host0[56][0-9] or specifically for just the file names you have, the example sigsegv would be appropriate. Think of whatever is in a box as being "either or" unless you use a - as a range.


All times are GMT -5. The time now is 11:42 PM.