Shell Programming and Scripting

BSD, Linux, and UNIX shell scripting — Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here.

'find' command inconsistency

👤 Login to reply

 
Thread Tools Search this Thread Display Modes
    #1  
Old 06-11-2010
soleil4716 soleil4716 is offline
Registered User
 
Join Date: Oct 2007
Last Activity: 24 October 2010, 8:11 PM EDT
Location: Dallas, Texas
Posts: 67
Thanks: 0
Thanked 2 Times in 2 Posts
'find' command inconsistency

I am seeing a strange behavior of the 'find' command on AIX. As you can see,
the find command sometimes finds the file and sometimes does not based on how
many characters I specified between the wildcards.

I know all of these issues
can be resolved by using double quotes like "*est*". But I am posting this to
see if any of you can explain why it is able to find the file when I
specified *estf* but could not when I used *est*.

Code:
/home/testuser>uname -a

AIX myhost 3 5 00080B19D600

/home/testuser>ls -al /tmp/testuser

-rw-r--r--    1 testuser   staff             0 Jun 09 17:29 testfile

/home/testuser>find /tmp/testuser -name *est*


/home/testuser>find /tmp/testuser -name *estf*
/tmp/testuser/testfile

Sponsored Links
    #2  
Old 06-11-2010
drl's Unix or Linux Image
drl drl is offline Forum Advisor  
Registered Voter
 
Join Date: Apr 2007
Last Activity: 21 May 2018, 12:52 PM EDT
Location: Saint Paul, MN USA / BSD, CentOS, Debian, OS X, Solaris
Posts: 2,223
Thanks: 260
Thanked 420 Times in 361 Posts
Hi.

Rerun both commands, but with echo in front of each one ... cheers, drl
Sponsored Links
    #3  
Old 06-11-2010
curleb curleb is offline Forum Advisor  
Registered User
 
Join Date: Mar 2008
Last Activity: 27 March 2017, 3:48 PM EDT
Location: Surrounded...
Posts: 383
Thanks: 1
Thanked 29 Times in 28 Posts
The find util has co-dependency issues and likes its globbed args to be held...preferably between double-quotes.

Seriously, it does not always behave as expected on globbed -name args. You'll want to make sure and wrap your args in proper quotes to ensure that find can parse them properly.
Code:
find /tmp/testuser -name *est*   -o -name *estf* 
# versus ... 
find /tmp/testuser -name "*est*" -o -name "*estf*"

    #4  
Old 06-12-2010
jlliagre jlliagre is offline Forum Advisor  
ɹǝsn sıɹɐlos
 
Join Date: Dec 2007
Last Activity: 19 July 2018, 4:43 PM EDT
Location: Outside Paris
Posts: 4,897
Thanks: 18
Thanked 650 Times in 565 Posts
The find command has no inconsistencies. If you don't quote parameters containing wildcards, they will be expanded before being passed to the find command if they match some existing filename. This is certainly true with your case.
As drl already wrote: echo will show you the root cause and demonstrate find isn't the issue here.
Sponsored Links
👤 Login to reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Variable value inconsistency on BASH and CSH pavanlimo Shell Programming and Scripting 2 04-08-2009 11:48 AM
File System inconsistency callitdctr UNIX for Dummies Questions & Answers 3 04-03-2009 03:22 AM
Backspace stty inconsistency Runrig HP-UX 1 06-30-2008 09:40 AM
packet inconsistency problem clalfa Ubuntu 1 03-17-2008 04:53 PM
Disk inconsistency Carmen123 UNIX for Dummies Questions & Answers 1 11-20-2006 10:10 AM



All times are GMT -4. The time now is 06:39 AM.

Unix & Linux Forums Content Copyright©1993-2018. All Rights Reserved.
×
UNIX.COM Login
Username:
Password:  
Show Password





Not a Forum Member?
Forgot Password?