将文件的自动删除添加到脚本文件的末尾

Adding an Auto Delete for files to the end of a Script File

所以我有一个脚本可以获取 2 个文件夹中的 zip 文件并将它们解压缩到新的文件夹中,所有这些都可以正常运行

(文件夹名称已更改)

但我想首先知道是否可以在文件解压缩并放置在正确的文件夹中之后删除旧的 zip 文件,这样我剩下的就是文件夹和所有解压缩的文件。

其次,如果是的话,我会怎么做呢?我是编写脚本的新手

感谢您提供的任何帮助

cd ~/Downloads/

mkdir -p -v "./prior/(Folder_Name_1)"
mkdir -p -v "./prior/(Folder_Name_2)"
mkdir -p -v "./prior/(Folder_Name_3)"

mkdir -p -v "./current/(Folder_Name_1)"
mkdir -p -v "./current/(Folder_Name_1)"
mkdir -p -v "./current/(Folder_Name_1)"

tar -xzvf "./prior/Name1.reports.tar.gz" -C "./prior/Folder_Name_1"
tar -xzvf "./prior/Name2.reports.tar.gz" -C "./prior/Folder_Name_2"
tar -xzvf "./prior/Name3.reports.tar.gz" -C "./prior/Folder_Name_3"

tar -xzvf "./current/Name1.reports.tar.gz" -C "./prior/Folder_Name_1"
tar -xzvf "./current/Name2.reports.tar.gz" -C "./prior/Folder_Name_2"
tar -xzvf "./current/Name3.reports.tar.gz" -C "./prior/Folder_Name_3"

我想你想要这样的东西

rm "./prior/Folder_1"
rm "./prior/Folder_2"
rm "./prior/Folder_3"

rm "./current/Folder_1"
rm "./current/Folder_2"
rm "./current/Folder_3"