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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Weird find Command Behavior 1

Status
Not open for further replies.

Michael42

Programmer
Oct 8, 2001
1,454
US
Hello,

In a Sun Solaris 8 environment using the Bourne shell scripts I commonly use the find command as show below:
Code:
find /mydir -name "*.ARC" -type f -mtime +5

On one system Sun Solaris 8 system however when I issue the above find I am getting the message: "find: cannot read dir /mydir/lost+found: Permission denied"

If I remove the -mtime +5 parameter it works fine, i.e. I have files that are displayed in my directory. I am so stumped because this works on other systems. [surprise]

What can you recommend?

Thanks,

Michael42
 
As root:
chmod ugo+rx /mydir/lost+found

Then you'll never have permission denied to read that directory.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 

Or justt re-direct the error to a null file:
Code:
find /mydir -name "*.ARC" -type f -mtime +5 2>/dev/null
[3eyes]


----------------------------------------------------------------------------
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
 
The funcky thing is that when my find breaks because it cannot deal with the lost+found directory my script does too. Because of this just outputing to standard error does not seem to be effective (thanks LKBrwnDBA).

I cannot have the permissions changed at this time (thanks PHV).

Can anyone please detail how to use the find command to exclude the /mydir/lost+found directory from a find command with the criteria\example above?

Thanks very much for helping me pound this one out,

Michael
 
You may try this:
find `ls -d /mydir/* | grep -v lost+found` -name '*.ARC' -type f -mtime +5

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
PHV,

That rocked! :)

Thanks very much for posting,

Michael42
 
That may be a workaround, but it doesn't answer the question why this is happening.

Can you check to see if you have the command "[tt]set -e[/tt]" in any of your startup scripts? That will cause the shell to exit if it hits any error. Type "[tt]echo $-[/tt]" and see if an "[tt]e[/tt]" is listed.

There MUST be some difference between this machine and the others (and mine).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top