2015-02-06 25 views
0

我想要從supplies csv文件中刪除文件,如果它超過1天。從csv列表中刪除超過1天的文件時出錯

我試圖把它們打印測試目的:

in.txt

1,one 
2,two 

代碼:

INPUT="in.txt" 
while IFS=',' read -r id name 
do 
    find tmp/$name -mtime +1 -type f 
done < "$INPUT" 

此代碼拋出錯誤:

find: bad status-- tmp/one 
find: bad status-- tmp/two 

感謝。

+1

嘗試'找到tmp -name $名稱-mtime ...'祝你好運。 – shellter 2015-02-06 16:11:26

+0

感謝它的工作 – user2711819 2015-02-06 16:20:18

回答

0

召回,對於find命令的形式是

find ${baseDir} -${options ......} args to opts. 

你的表格是說

find tmp/$name -mtime +1 -type f 
# --^^^^^^^^^^ -- start looking in dir tmp/$name 

你可能想說保持-type f可能不需要

find tmp -name $name -mtime +1 -type f 
#---^^^^^ start looking in the tmp dir 

,但它會阻止你匹配目錄而不是文件。 IHD。

IHTH。

相關問題