Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to explains such "find" behaviour? 3

Status
Not open for further replies.

w5000

Technical User
Nov 24, 2010
223
PL
why find doesn't return/find anything then invoked from / directory???

The same behaviour with gnufind (findutils-4.4.2-2)
The same behaviour on root and non-root accounts.


Code:
# find /data/idx/* -ctime +93 -type d -name [0-9][0-9][A-Z][A-Z][A-Z][0-9][0-9] -print
/data/idx/N/19MAY11
/data/idx/N/20MAY11
/data/idx/N/21MAY11
/data/idx/N/22MAY11
/data/idx/N/23MAY11
/data/idx/N/24MAY11
# cd /
# find /data/idx/* -ctime +93 -type d -name [0-9][0-9][A-Z][A-Z][A-Z][0-9][0-9] -print
# cd /usr
# find /data/idx/* -ctime +93 -type d -name [0-9][0-9][A-Z][A-Z][A-Z][0-9][0-9] -print
/data/idx/N/19MAY11
/data/idx/N/20MAY11
/data/idx/N/21MAY11
/data/idx/N/22MAY11
/data/idx/N/23MAY11
/data/idx/N/24MAY11
# cd /
# find /data/idx/* -ctime +93 -type d -name [0-9][0-9][A-Z][A-Z][A-Z][0-9][0-9] -print
#

# find /data/idx/ -ctime +93 -type d -name [0-9][0-9][A-Z][A-Z][A-Z][0-9][0-9] -print
# find /data/idx -ctime +93 -type d -name [0-9][0-9][A-Z][A-Z][A-Z][0-9][0-9] -print
# ls -ld /data/idx
drwxrwxr-x   11 lido     lido           4096 Jul 04 07:19 /data/idx
#
 
How weird.

Do you get the same result if you type which find in both locations? Any symlinks in that /data/idx path (not that it should matter)?

What OS exactly?

Annihilannic
[small]tgmlify - code syntax highlighting for your tek-tips posts[/small]
 
That is weird.

You've got two things in the command line that the shell will try to expand before executing the line. Try this command in both locations...
Code:
find /data/idx -ctime +93 -type d -name '[0-9][0-9][A-Z][A-Z][A-Z][0-9][0-9]' -print
I have no idea if it will help, but I'd like to see what it does.

Also, can you do an "ls -lad /" so we can see what the root directory has for perms.

 
I think SamBones gave you the hint in the right direction. Most likely there is a file in the root directory that matches your regex. With that assumption the behavior is reproducible:
Code:
srvap05:~# touch /tmp/homx
srvap05:~# cd /
srvap05:/# ls -d hom[a-z]
home
srvap05:/# find /tmp -name hom[a-z] -print
srvap05:/# find /tmp -name 'hom[a-z]' -print
/tmp/homx
 
indeed, I've found a dir in / matching the regex

thank you for your valuable tips.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top