LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
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.

Notices

Reply
 
Search this Thread
Old 12-15-2004, 03:54 PM   #1
dazdaz
Member
 
Registered: Aug 2003
Location: Europe
Distribution: RHEL 6.x, 5.x, Fedora 20, Kubuntu 12.04, Solaris 10,8
Posts: 321

Rep: Reputation: 17
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
 
Old 12-15-2004, 04:12 PM   #2
sigsegv
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
host[56][901]*
 
Old 12-15-2004, 04:31 PM   #3
XavierP
Moderator
 
Registered: Nov 2002
Location: Kent, England
Distribution: Lubuntu
Posts: 19,174
Blog Entries: 4

Rep: Reputation: 428Reputation: 428Reputation: 428Reputation: 428Reputation: 428
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
amfoster
Member
 
Registered: Aug 2004
Distribution: debian, SuSE
Posts: 365

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


Reply


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 8 12-18-2013 05:36 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


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

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