I've cobbled together what is below, and it seems to work, with the possible exception of the "! -empty". One thing I'm learning (as I go) is that just because something works, doesn't mean it's right or formed correctly...The question I have is how do you determine what requires parentheses and what doesn't in a find command?
In OS X, -and is "implied by the juxtaposition of two expressions it does not have to be specified"
My goal is to have find: find directories that are over 5 minutes old, not empty, and are not .dot (hidden -i.e. "." and "..")
count="$( find . -type d -mmin +5 \! -empty \( ! -iname ".*" \) | wc -l )"
echo $count
if [ "$count" -gt 0 ] ; then
echo $(date +"%r") "$cust_name loc 9: "${count}" directories exist to process, moving them" >> $logFILE
find . -type d -mmin +5 \! -empty \( ! -iname ".*" \) | xargs -I % mv % ../02_processing/
cd $processingPATH
# append the time and the directories to be processed in files_sent.txt
date +"---- %a-%b-%d %H:%M ----" >> $filesSENTlog
ls >> $filesSENTlog
find . -type f -print0 | xargs -0 /usr/local/dcm4che-2.0.28/bin/dcmsnd $aet@$peer:$port
echo $(date +"%r") "$cust_name loc 10: Processing ${count} items..." >> $logFILE
# clean up processed studies > from processing to processed
echo $(date +"%r") "$cust_name loc 11: Moving ${count} items to 03_processed" >> $logFILE
mv * $processedPATH
else
echo $(date +"%r") "$cust_name loc 12: there are no directories to process" >> $logFILE
fi
could I just do:
find . -type d -mmin +5 \! -empty \! -iname ".*"
? or is that not correct for some reason?
find . -type d -mmin +5 \! -empty \! -iname ".*"
equivalent tofind . -type d -mmin +5 \! -empty \( ! -iname ".*" \)
- right? – Tie