Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - General
User Name
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.


  Search this Thread
Old 12-15-2004, 03:54 PM   #1
Registered: Aug 2003
Location: Europe
Distribution: RHEL, CentOS, Ubuntu
Posts: 330

Rep: Reputation: 17
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.

Old 12-15-2004, 04:12 PM   #2
Senior Member
Registered: Nov 2004
Location: Third rock from the Sun
Distribution: NetBSD-2, FreeBSD-5.4, OpenBSD-3.[67], RHEL[34], OSX 10.4.1
Posts: 1,197

Rep: Reputation: 46
Old 12-15-2004, 04:31 PM   #3
Registered: Nov 2002
Location: Kent, England
Distribution: Debian Testing
Posts: 19,192
Blog Entries: 4

Rep: Reputation: 474Reputation: 474Reputation: 474Reputation: 474Reputation: 474
Moved: This thread is more suitable in Linux-General and has been moved accordingly to help your thread/question get the exposure it deserves.
Old 12-15-2004, 08:50 PM   #4
Registered: Aug 2004
Distribution: debian, SuSE
Posts: 365

Rep: Reputation: 35
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.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Find/grep command to find matching files, print filename, then print matching content stefanlasiewski Programming 9 06-30-2016 05:30 PM
unexpected chmod behaviour ruzle0 Linux - Newbie 2 11-28-2005 02:06 PM
How can I find out the reason of unexpected reboot (redhat3+2.6.11)? yuzuohong Linux - General 2 05-24-2005 05:49 PM
Unexpected Behavior (passwd command) Penguin666 Linux - General 3 11-19-2003 11:34 PM
cp command problem..... unexpected result hamster Linux - General 2 04-10-2003 04:57 PM > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 04:26 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration