Unexpected behaviour with the find command
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]*"
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.
Moved: This thread is more suitable in Linux-General and has been moved accordingly to help your thread/question get the exposure it deserves.
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[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 07:55 PM.|