(GNU)使用变量查找-mtime

时间:2015-06-18 08:30:49

标签: linux variables unix find gnu

我尝试使用-mtime +(variable)查找文件,但每次我在GNU中执行下面时都会收到错误:

  

找到:缺少`-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

1 个答案:

答案 0 :(得分:1)

添加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