我试图使用-mtime +(variable)
查找文件,但每次在gnu中执行以下操作时,我都会收到一个错误:
find:“-mtime”缺少参数
在aix上试过了,结果成功了。
#------config-------#
cat hkeep.cfg
#<Directory to be purge>,<Days to Purge>
/home/fbmadm/logs,15
#------MAIN-------#
for line in `cat hkeep.cfg | grep -v "#"`;do
hkDir=`echo $line | awk -F"," '{print $1}'`
hkCnt=`echo $line | awk -F"," '{print $2}'`
find $hkDir -mtime +$hkCnt
done
最佳答案
添加echo line
可以帮助您解决问题:
for line in `cat hkeep.cfg | grep -v "#"`;do
hkDir=`echo $line | awk -F"," '{print $1}'`
hkCnt=`echo $line | awk -F"," '{print $2}'`
echo find $hkDir -mtime +$hkCnt
find $hkDir -mtime +$hkCnt
关于linux - (GNU)使用变量查找-mtime,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/30910241/