LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 09-22-2008, 10:28 PM   #1
sharky
Member
 
Registered: Oct 2002
Posts: 569

Rep: Reputation: 84
Question about find utility


I can't seem to get find to use both -prune and -size together. I want to find files over a certain size and at the same time exclude certain directories.

I'm able to do one or the other but not both simultaneously.

To find files of a certain size I use this in a bash script.

Code:
find $1 -user $USER -type f -size +600k -exec ls -lh {} \;
To exclude certain paths in the find I use this.

Code:
find $1 -user $USER -type f -size +100k -path $1/.snapshot -prune -o -print -exec ls -lh {} \;
The second statement excludes the .snapshot directory but I'm getting all file sizes returned and not just the ones over 100k. It also appears that the -user flag is ignored.

What am I doing wrong?
 
Old 09-23-2008, 01:08 AM   #2
Woodypecker
Member
 
Registered: Mar 2006
Location: Austria
Distribution: Mandriva/Debian
Posts: 104

Rep: Reputation: 17
The "-o" is actually "or". IMHO the ordering of parameters matter in that case, try to put the other conditions right to the prune.
 
Old 09-23-2008, 02:54 AM   #3
theYinYeti
Senior Member
 
Registered: Jul 2004
Location: France
Distribution: Arch Linux
Posts: 1,897

Rep: Reputation: 66
It should be:
Code:
find $1 -path $1/.snapshot -prune -o -user $USER -type f -size +600k -exec ls -lh {} \;
Yves.
 
Old 09-23-2008, 10:19 AM   #4
sharky
Member
 
Registered: Oct 2002
Posts: 569

Original Poster
Rep: Reputation: 84
Quote:
Originally Posted by theYinYeti View Post
It should be:
Code:
find $1 -path $1/.snapshot -prune -o -user $USER -type f -size +600k -exec ls -lh {} \;
Yves.
This appears to work. Thanks.
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
'locate' utility can't find db imputerate Linux - Newbie 9 05-26-2008 05:52 AM
unix find utility shamgar03 Linux - Software 8 08-09-2007 04:06 PM
Utility to find C function defintions, variables, etc... stingerkiss Linux - Software 1 11-19-2006 03:35 PM
Utility to find out FSB siddiqu Linux - Hardware 5 06-16-2003 12:10 AM
What's in my computer/Utility to find out geraldgu Linux - Software 2 12-14-2001 12:04 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 10:36 PM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration