Please suggest me a better option than FIND command


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Please suggest me a better option than FIND command
# 1  
Old 10-25-2010
Please suggest me a better option than FIND command

Hi All,

Could you please help me in searching files in a better way satisfying the below conditions

I want to search files in a path whose access time is more than 5min and less than 60 min and whose Byte size is greater than zero

For this, i am using the below command, but it is consuming lot of time. Can someone of you please suggest me a better option .

Code:
find /home/sparks -type f \( -mmin +5 -a -cmin -60 \) -size +0 -ls | egrep -v '|subscriptions|sent|outbox'



Thanks in advance !!!
# 2  
Old 10-25-2010
I don't think that there is any "better" option than to use find. Still, your find-command could well be optimized by throwing out the pipe.

Instead of:
Quote:
Originally Posted by sparks
Code:
find /home/sparks -type f \( -mmin +5 -a -cmin -60 \) -size +0 -ls | egrep -v '|subscriptions|sent|outbox'

Code:
find /home/sparks -type f  \
                         ! \( -name "subscriptions*" -o -name "sent" -o -name "outbox*" \)
                         \( -mmin +5 -a -cmin -60 \) -size +0 -ls

You might have to fine-tune the file-globs a bit, depending on how exact your file mask in egrep was phrased. Either way you will perhaps save execution time because you don't have to process all the data only once instead of twice.

I hope this helps.

bakunin
# 3  
Old 10-25-2010
Java

What OS ? What FileSystem?
How many subdirectories? files?

Is it really access time you are interested in or modified time?
cmin change of file status.
mmin modification time.
You are comparing apples and PCs.Smilie
amin is access time
Many systems have volumes with atime updates disabled!

If you are really looking for an non empty file
-not -empty may be better.
But if you are looking for a file that has some content specifying a more specific size range may reduce the number of other tests performed.

I don't know if find optimize the tests? By that I mean:
Does it matter what order the options are specified in?
Anyone out there know??

sparks:"We'd all like to know what you find out".Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Prune Option for Find Command on AIX

I need to delete all files from the working directory and its sub directories using the find command, for that I am using -prune option but some how I am having a syntax issue. I have tried the below, please help me correct the syntax find . -name \* -type f -exec rm -f {} \; >> Works but... (4 Replies)
Discussion started by: rosebud123
4 Replies

2. Shell Programming and Scripting

Maxdepth option of find command not working

Can you please figure out what is the issue here $ find . -maxdepth 1 -type f -size 0 -print find: bad option -maxdepth please find the OS details $ uname -a HP-UX g5u1216 B.11.31 U ia64 2614088426 unlimited-user license Use code tags, thanks. (6 Replies)
Discussion started by: TomG
6 Replies

3. Shell Programming and Scripting

Variable inside -name option for find command

Hi, I am not able to get output for find command if there are variables defined inside -name option . Please check below example 1) ###VARIABLES DEFINED process="fast" temperature="125c" voltage="0p935v" 2) I don't get output for below find command find -L <PATH> -type f \( -name... (2 Replies)
Discussion started by: gujrathinr
2 Replies

4. UNIX for Dummies Questions & Answers

AIX find command using prune option

Hi, I am trying to find some files in a directory and then remove/list them if they are 30 days old. I also have 2 directories in that directory which I need to skip. Can someone please tell me what is the correct syntax? find /developer/. -name "lost+found" "projects" -prune -o -type f... (2 Replies)
Discussion started by: tkhan9
2 Replies

5. Shell Programming and Scripting

Confusing find command option

Hi, I am a little bit confusing of using find command. Actually, I am planning to delete the files whatever the files are existing in the day before yesterday. So, I am writing the command like this. find . -name "*.txt" -ctime -2 { here I am confusing, if I will use +2 or +1 also I am... (5 Replies)
Discussion started by: nagraju.allam
5 Replies

6. Shell Programming and Scripting

complicated exclude option in find command

Hi all, In a directory, I have many video files. Example : As you can see, some of the video files come with a .aspx file (wich means the video is actually being uploaded and not entirely written on the FS) I try to write a bash script that would find all video files in the ... (1 Reply)
Discussion started by: gniagnia
1 Replies

7. Shell Programming and Scripting

daystart option not working in find command

Hi, I am trying to list all the files created / modified today in a directory. With reference to this thread, https://www.unix.com/shell-programming-scripting/20324-capture-all-today-files.html I have used the below command to list all the files modified today. find . -daystart -type f... (8 Replies)
Discussion started by: arunkumarmc
8 Replies

8. Shell Programming and Scripting

help with find command and prune option

Hi I have a directory say mydir and inside it there are many files and subdirectories and also a directory called lost+found owned by root user I want to print all files directories and subdirectorres from my directory using find command except lost+found If i do find . \( -name... (3 Replies)
Discussion started by: xiamin
3 Replies

9. UNIX for Dummies Questions & Answers

help me out with find command , -prune option

Hi , Kindly help me out .:) i want to find only the file t4 in directory t3. i am in dir t . the tree is as follows. if i give, find . o/p is . ./t4 ./t1 ./t1/t2 ./t1/t2/t3 ./t1/t2/t3/t4 ./t1/t2/t4 ./t1/t4 directories are like t/t1/t2/t3 and each directory has file t4. my... (7 Replies)
Discussion started by: bhuvaneshlal
7 Replies

10. Shell Programming and Scripting

unix find command without mmin option

I need to check if a file has been modified within the last x hours. My find command does not have the mmin option -- only the mtime option which is in 24 hour perriods (1 Reply)
Discussion started by: Bill Ma
1 Replies
Login or Register to Ask a Question