Find files of specific size excluding search in a subdirectory


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Find files of specific size excluding search in a subdirectory
# 1  
Old 04-12-2010
Find files of specific size excluding search in a subdirectory

Hi All,
I was exploring find command and came across -prune option which would exclude search in a mention subdirectory.
My quesry is to search all files more that 100 MB size but exclude search in a subdirectory.

I am using below command,but somehow it is not working.
Can anybody help me understand where i am going wrong.
Thanks in advance. Smilie

Code:
 
find /logs \( -name /logs/wu01/tmpbuild -prune \) -type f -size +1000k

# 2  
Old 04-12-2010
Code:
find /logs \( -name /logs/wu01/tmpbuild -prune \)  -a \( -type f -size +100M \) -print

# 3  
Old 04-12-2010
-prune: If -depth is not given, true; do not descend the current direc-
tory.
If -depth is given, false; no effect.
# 4  
Old 04-12-2010
PHP Code:
-prune: If -depth is not giventrue; do not descend the current direc
tory
If -
depth is givenfalseno effect
Hi Devtakh,
Thanks for replying.
But Could you please explain that.
Is that command correct.
Actually i want to search the directory /logs without searching the sub directory /logs/wu01/tmpbuild and find all files of size more that 100 MB.

With above command i am not getting result though.
Thanks

---------- Post updated at 10:36 PM ---------- Previous update was at 10:11 PM ----------

PHP Code:
usha find /logs \( -name /logs/wu01/tmpbuild -prune \)  -\( -type f -size +1000 \) -print
find: /logs/wu01/tmpbuild/xyz/abcPermission denied
find
: /logs/wu01/tmpbuild/defPermission denied 
Hi Dinjo,

Even with the code you have given,it is still searching in /logs/wu01/tmpbuild
# 5  
Old 04-12-2010
Try this

Code:
find logs/* -prune -size +100 -print


cheers,
Devaraj Takhellambam
# 6  
Old 04-12-2010
Quote:
Originally Posted by usha rao
Code:
 
find /logs \( -name /logs/wu01/tmpbuild -prune \) -type f -size +1000k

-name only matches against the basename, so that -name primary will never match, since forward slashes cannot occur in a basename. What you want is to use -path. Also, you need to or (-o) the tempbuild-prune related primaries or they will cause the expression evaluated by find to be false for all non-pruned pathnames (meaning find will never match anything).

Code:
 
find /logs \( -path /logs/wu01/tmpbuild -prune \) -o \( -type f -size +1000k \)

Regards,
Alister

Last edited by alister; 04-12-2010 at 03:16 AM..
# 7  
Old 04-12-2010
Hi Devraj and Alister,
Thanks a lot to both of you.
The solution
Code:
find /logs \( -path /logs/wu01/tmpbuild -prune \) -o \( -type f -size +1000k \)

Worked for me..
Cheers
Usha
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to sort the files by size and based subdirectory un UNIX?

I have the below input data in a file and need to get the output as mentioned below. Need to sort the data by size(Asc/des)/by subdirectory Below is the input which is there in a file: 120 /root/path2/part-00000-d3700305-428d-4b13-8161-42051f4ac5ed-c000.json 532 ... (3 Replies)
Discussion started by: ajarramuk
3 Replies

2. Shell Programming and Scripting

Search for specific file type in subdirectory with multiple folders

I have a directory that is in the below order (the --- is not part of the directory tree, only there to help illustrate: DATE --- main level Folder1 --- level under DATE plugin_out --- level under Folder1 variantCaller_out.40 --- level under plugin_out 001,002,003 --- level under... (3 Replies)
Discussion started by: cmccabe
3 Replies

3. Shell Programming and Scripting

Find command to search files in a directory excluding subdirectories

Hi Forum, I am using the below command to find files older than x days in a directory excluding subdirectories. From the previous forums I got to know that prune command helps us not to descend in subdirectories. Though I am using it here, not getting the desired result. cd $dir... (8 Replies)
Discussion started by: jhilmil
8 Replies

4. UNIX for Dummies Questions & Answers

How to Find files in subdirectory?

I am trying to find all DAT files in a subdirectory named IN. I do not know the entire path. For example: /stage/<?>/<?>/IN/file.DAT I am using the find command without success: find /stage -name IN -a -name '*.DAT' -print What is the correct logic and syntax? Thank you for the help. (5 Replies)
Discussion started by: TwinGT
5 Replies

5. Shell Programming and Scripting

Search for file and size subdirectory as well

Hi I made this code to search in directory for file and size How can I remodel it to seach in the sub direcotry as well Thanks #!/bin/bash echo -n "Enter: " read var if then echo "Directory exists: ${var}" size=`du -hs "${var}"` echo The size of the current folder is... (4 Replies)
Discussion started by: lio123
4 Replies

6. Shell Programming and Scripting

search text in files within the subdirectory

Hello, I am trying to write a shell script to search for a pattern in the directory and show only one entry for each field, essentially I am looking to search for a pattern in a file and list that file name. (1 Reply)
Discussion started by: grajp002
1 Replies

7. Shell Programming and Scripting

Find files in directory and its subdirectory

I am writing a script which reads a file line by line and then assigns it to a variable like this 1090373422_4028715212.jpg. I have images with file name of this format in some other directory. In my script I want to assign variable with this file name and then find this filename in some other... (11 Replies)
Discussion started by: jyotib
11 Replies

8. Shell Programming and Scripting

Find files including subdirectory and Delete

Hello Experts, I m newbie. Could u pls help me to write script on Sun solaris- I have backup directory "/var/opt/backup/" where files are backed up in different directory "backup1" "backup2" "backup3". I want to write a shell script which i will put in crontab and daily midnight it will... (1 Reply)
Discussion started by: thepurple
1 Replies

9. Shell Programming and Scripting

search for files excluding binary files

Hi All, I need a solution on my following find command find ./.. -name '*.file' -print BTW This gives me the output as belows ./rtlsim/test/ADCONV0/infile/ad0_dagctst.file ./rtlsim/test/ADCONV0/user_command.file ./rtlsim/test/ADCONV0/simv.daidir/scsim.db.dir/scsim.db.file... (2 Replies)
Discussion started by: user_prady
2 Replies

10. Solaris

command to find out total size of a specific file size (spread over the server)

hi all, in my server there are some specific application files which are spread through out the server... these are spread in folders..sub-folders..chid folders... please help me, how can i find the total size of these specific files in the server... (3 Replies)
Discussion started by: abhinov
3 Replies
Login or Register to Ask a Question