我正在嘗試tar文件超過3天。我回顧了現有的問題creating tar file and naming by current date,但是當我運行腳本時,文件不會被修改。有沒有人有一些提示?如何使用Bash tar文件中的文件
# Tar files older than 3 days
files=($(find /this/is/my_path/ -type f -mtime +3))
tar -cvfz backup.tar.gz "${files[@]}"
if [ ! -f ${LOGFILE}.tar.gz ]; then
Error checking
if [ $? -ne 0 ]; then
Process_Error $ERROR_SUM "This file had a problem $FILE!"
fi
fi
}
嘗試'-cvzf'您正在創建一個名爲'z'的文件。 – 123
另外,'files =($(find/this/is/my_path/-type f -mtime +3))'不適用於名稱中帶有空格的文件('some file.txt'將成爲兩個條目, 'some'和'file.txt')。並且'/ this/is/my_path/*重要* .txt'會將第一個*替換爲當前目錄中的文件列表,並將* .txt替換爲文本文件列表。 –
請參見:[查找文件並將其tar(帶空格)](http://stackoverflow.com/q/5891866/3776858) – Cyrus