Finding new file, but excluding directory..


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Finding new file, but excluding directory..
# 1  
Old 11-22-2012
Finding new file, but excluding directory..

hi,

I need to find files that have been created less than 3 days ago. However, I need to only search specific directories.

I've searched about the net and found some useful commands such as :

Code:
find . -type d -name 'dir_to_exclude' -prune -o -print -mtime -3

however I cannot get it working to what I want. I'm using Solaris.

Anyone any hints they could give me.

for example, the directory that I wish to search is called:

/work

however, in this directory I wish to exclude this directory:

/work/directorylocation

so how could I do this i.e.

find files in /work only created within 3 days, but also excluding /work/directorylocation

thanks for any help

Last edited by vbe; 11-22-2012 at 12:55 PM..
# 2  
Old 11-22-2012
Code:
find /work/* \( -type d ! -name . -prune \) -o \( -type f -name "*" -mtime +3 -print \)


Last edited by Yoda; 11-22-2012 at 12:56 PM..
# 3  
Old 11-22-2012
Maybe I misunderstood the request, but I'm not sure that I see how bipinajith's command does what was requested. If I understand the request correctly, I think horhif wanted something more like:
Code:
find /work \( -name directorylocation  -prune \) -o -mtime -3

which will print a list of files in the file hierarchy rooted in /work except for /work/directorylocation and the files in and under it.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Find file with extension and excluding directory

Hi, I have an inquiry on how do I use the find command in Solaris Unix to find some file ends with extension : txt, err in the root directory with modified date of 30days and this find command will also need to exclude b directory and its subdirectory. All the files from the above find criteria... (5 Replies)
Discussion started by: snowfrost88
5 Replies

2. Shell Programming and Scripting

Finding the file name in a directory with a pattern

I need to find the latest file -filename_YYYYMMDD in the directory DIR. the below is not working as the position is shifting each time because of the spaces between(occuring mostly at file size field as it differs every time.) please suggest if there is other way. report =‘ls -ltr... (2 Replies)
Discussion started by: archana25
2 Replies

3. Shell Programming and Scripting

Finding duplicates in a file excluding specific pattern

I have unix file like below >newuser newuser <hello hello newone I want to find the unique values in the file(excluding <,>),so that the out put should be >newuser <hello newone can any body tell me what is command to get this new file. (7 Replies)
Discussion started by: shiva2985
7 Replies

4. Shell Programming and Scripting

Excluding a directory

i want to search files in public_html of all users and exclude any directories named "uploads" or "albums" (because there are many files in these), just skip them completely now im doing something like find /home/*/public_html -regex ".*\(php\|html\|htm\)$" -path albums -prune -o -type f... (1 Reply)
Discussion started by: vanessafan99
1 Replies

5. UNIX for Dummies Questions & Answers

finding files in unix and excluding certain folders

hi good day I am using redhat linux. Is there a better utility than the 'find' command to search for files I am trying to search through and enitre directory such as /repos for a files that have 'UAP' in it. However there are some '.step' folders littered throughout the /repos folder at varying... (8 Replies)
Discussion started by: johnstrong
8 Replies

6. Shell Programming and Scripting

Excluding directory during deleting

Hi all, I'm trying to work on a script to delete files older then 31 day's in certain directories. Now, that works, but in one directory there are 3 other maps which contains files that can be deleted but one map which contains files that can't be deleted. My current command is: find... (6 Replies)
Discussion started by: JasperG
6 Replies

7. UNIX and Linux Applications

Finding the oldest file in a directory without ls

I am trying to determine the oldest and most recent files in a huge directory. I am using an ls -tr statement outside my find statement. The directory is too big and I am getting an "arg list too long" error. Is there something I can put in my find statement that doesn't create a list to... (2 Replies)
Discussion started by: hiyofjord
2 Replies

8. Shell Programming and Scripting

Finding the oldest file in a particular directory

Hi all, I am a newbie to scripting and I need your help regarding finding the oldest file in a particular directory. My intention is to remove that oldest file. Are there any options available with the "find" command to do this.. Thanks in advance for your help Pavan (4 Replies)
Discussion started by: pavan_movva
4 Replies

9. UNIX for Advanced & Expert Users

find excluding a directory and a file

Hi I have some 5 folders and two files in the current directory. I want to delete all, expect one folder(files in the folder too should not be deleted) and a file in the current directory. Lets say the folder and file that should not be deleted as 'a'(folder name) and 'b'(file name). Can you... (1 Reply)
Discussion started by: ammu
1 Replies

10. UNIX for Dummies Questions & Answers

finding file in a directory

hi can i know how to locate a file in a directory by using the "find" command? i want to know the exact path the files reside in in the result. thanks :confused: (4 Replies)
Discussion started by: legato
4 Replies
Login or Register to Ask a Question