Unix/Linux Go Back    


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

Shell Programming and Scripting


Closed    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 06-11-2010   -   Original Discussion by soleil4716
soleil4716's Unix or Linux Image
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 Unix and Linux 06-12-2010   -   Original Discussion by soleil4716
drl's Unix or Linux Image
drl drl is online now Forum Advisor  
Registered Voter
 
Join Date: Apr 2007
Last Activity: 15 December 2017, 10:36 AM EST
Location: Saint Paul, MN USA / BSD, CentOS, Debian, OS X, Solaris
Posts: 2,212
Thanks: 250
Thanked 417 Times in 358 Posts
Hi.

Rerun both commands, but with echo in front of each one ... cheers, drl
Sponsored Links
    #3  
Old Unix and Linux 06-12-2010   -   Original Discussion by soleil4716
curleb's Unix or Linux Image
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 Unix and Linux 06-12-2010   -   Original Discussion by soleil4716
jlliagre's Unix or Linux Image
jlliagre jlliagre is offline Forum Advisor  
ɹǝsn sıɹɐlos
 
Join Date: Dec 2007
Last Activity: 13 December 2017, 3:12 AM EST
Location: Outside Paris
Posts: 4,876
Thanks: 18
Thanked 637 Times in 556 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
Closed

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux 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 12:48 PM
File System inconsistency callitdctr UNIX for Dummies Questions & Answers 3 04-03-2009 04:22 AM
Backspace stty inconsistency Runrig HP-UX 1 06-30-2008 10:40 AM
packet inconsistency problem clalfa Ubuntu 1 03-17-2008 05:53 PM
Disk inconsistency Carmen123 UNIX for Dummies Questions & Answers 1 11-20-2006 11:10 AM



All times are GMT -4. The time now is 11:49 AM.