LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-09-2008, 06:42 AM   #1
sun_sun
LQ Newbie
 
Registered: Nov 2007
Posts: 21

Rep: Reputation: 15
Problem in using "find"


hi,

i just got stuck using unix "find" command.

while searching, i want it to leave some directories.

there is -wholename "./dir" -prune for that, but it is not supported here.

i tried using :

find . -path "./dir" -size +1000k -prune -o -exec du -hs {}\;

doesn't seem to work.. this shows me file more than 1000k in directory "dir" as well, which i want to exclude the search in.

what am i doing wrong ?

thanks,
sun_sun
 
Old 02-09-2008, 12:37 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
What is the final objective of the exercise? You want the sizes
of directories with less than 1000k content?



Cheers,
Tink
 
Old 02-09-2008, 02:06 PM   #3
sun_sun
LQ Newbie
 
Registered: Nov 2007
Posts: 21

Original Poster
Rep: Reputation: 15
Final objective -

-dir1 contains dir2

-i want to search in dir1, but leave searching in dir2

-does size of file matter ? even if i search for +100k or +10000k.

-anyways, i wanted to search for directories > 100Mb ( -type d -size +100000k [ in dir1, leave searching in dir2] ---- this is ok, right ? )


Quote:
Originally Posted by Tinkster View Post
What is the final objective of the exercise? You want the sizes
of directories with less than 1000k content?



Cheers,
Tink

Last edited by sun_sun; 02-09-2008 at 02:07 PM.
 
Old 02-09-2008, 06:13 PM   #4
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Quote:
Originally Posted by sun_sun View Post
Final objective -

-dir1 contains dir2

-i want to search in dir1, but leave searching in dir2

-does size of file matter ? even if i search for +100k or +10000k.

-anyways, i wanted to search for directories > 100Mb ( -type d -size +100000k [ in dir1, leave searching in dir2] ---- this is ok, right ? )
Not quite, because directories don't reflect the size
of their content. E.g. if dir1 has a file my_flick.mov
greater 100000 then the file will get listed, but the directory
that has the file won't.

You're better off to do a du -k on the directories, and then
filter out matching ones using awk or something ....

Code:
find . -type d -exec du -k {} \; |awk '$1 > 100000'


Cheers,
Tink
 
Old 02-10-2008, 01:38 AM   #5
sun_sun
LQ Newbie
 
Registered: Nov 2007
Posts: 21

Original Poster
Rep: Reputation: 15
But the basic question was "how to find in dir1, and not search in dir2(which is contained in dir1) using find"....which still remains a worry to me ..



Quote:
Originally Posted by Tinkster View Post
Not quite, because directories don't reflect the size
of their content. E.g. if dir1 has a file my_flick.mov
greater 100000 then the file will get listed, but the directory
that has the file won't.

You're better off to do a du -k on the directories, and then
filter out matching ones using awk or something ....

Code:
find . -type d -exec du -k {} \; |awk '$1 > 100000'


Cheers,
Tink
 
Old 02-10-2008, 01:52 AM   #6
ghostdog74
Senior Member
 
Registered: Aug 2006
Posts: 2,697
Blog Entries: 5

Rep: Reputation: 244Reputation: 244Reputation: 244
Code:
find -type d -name dir2 -prune -o -name "file" -type f -print
 
  


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
Shell Script: Find "Word" Run "Command" granatica Linux - Software 5 07-25-2007 07:42 AM
Several "find -exec" and "find | xargs" questions thanhvn Programming 4 12-02-2005 01:04 PM
Can't install "glibmm" library. "configure" script can't find "sigc++-2.0&q kornerr Linux - General 4 05-10-2005 02:32 PM
Where can I find the "make" & "cc" packages?? sayeed_ather Mandriva 2 04-28-2004 02:02 AM
"host" ok, but "ping" can't find ip address hardigunawan Linux - Networking 2 05-16-2002 05:41 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:55 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