Apoc Posted March 8, 2005 Report Share Posted March 8, 2005 (edited) all, i ahve the following command: for archivefile in $(find ${LOGDIR} -type f -mtime +5 -name "WH*" ) do echo $archivefile done This lists all files beginning with WH and older than 5 days. This works fine. Now i have created a similar script: for archivefile in $(find ${LOGDIR} -type f -mtime +5 -name "WH*" -o -name "D*" -o -name "0*") do echo $archivefile done this does not work it will list all the files WH older than 5 days but will list all files beginning with D and 0 regardless of how old they are.. what am i doing wrong? do i need the -mtime between each -o or is there an easier way?? ta. Edited March 9, 2005 by Apoc Quote Link to comment Share on other sites More sharing options...
ramfree17 Posted March 9, 2005 Report Share Posted March 9, 2005 i am not sure so i will stab at it. why not use an and operator to find? you will have to figure out the sequence they are evaluated but i am suggesting to the likes of -m +5 -a ( -name "" -o -name "" -o ...) or wait till one of the cli junkies arrive. :) ciao! Quote Link to comment Share on other sites More sharing options...
Steve Scrimpshire Posted March 9, 2005 Report Share Posted March 9, 2005 I'm sure aru will have the correct answer, but my guess is it needs to be this: for archivefile in $(find ${LOGDIR} -type f -mtime +5 -name "WH*" -o -type f -mtime +5 -name "D*" -o --type f -mtime +5 name "0*") Quote Link to comment Share on other sites More sharing options...
Apoc Posted March 9, 2005 Author Report Share Posted March 9, 2005 I'm sure aru will have the correct answer, but my guess is it needs to be this: for archivefile in $(find ${LOGDIR} -type f -mtime +5 -name "WH*" -o -type f -mtime +5 -name "D*" -o --type f -mtime +5 name "0*") <{POST_SNAPBACK}> They both seemed to work but i have used the above example so others in my department can see whats happening. Thanks. Quote Link to comment Share on other sites More sharing options...
Steve Scrimpshire Posted March 9, 2005 Report Share Posted March 9, 2005 My vote goes to ramfree's command since it works. It looks cleaner. :D Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.