【发布时间】:2014-08-11 21:22:51
【问题描述】:
我拼凑了下面的内容,它似乎可以工作,除了“!-empty”可能是个例外。我正在学习的一件事(当我去的时候)是,仅仅因为某些东西有效,并不意味着它是正确的或形成正确的......我的问题是你如何确定什么需要括号,什么不需要括号命令?
在 OS X 中,-and 是“通过两个表达式的并置来暗示它不必指定”
我的目标是找到: 查找超过 5 分钟、不为空且不是 .dot 的目录(隐藏 - 即“.”和“..”)
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
我可以这样做吗:
find . -type d -mmin +5 \! -empty \! -iname ".*"
?还是因为某种原因不正确?
【问题讨论】:
-
所以你的问题归结为:
find . -type d -mmin +5 \! -empty \! -iname ".*"是否等同于find . -type d -mmin +5 \! -empty \( ! -iname ".*" \)- 对吧? -
那个,什么决定了括号的使用。也有帮助的是,专门在 find 中使用括号的正确术语是什么。我不太了解它的用法-所以当我能弄清楚它的具体名称时,我会进行搜索……最后,它是好是坏还是丑陋? :-)