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

时间:2015-01-29 16:10:38

标签: bash terminal

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

(文件夹名称已更改)

但是我想首先知道是否有可能在文件被解压缩后放在正确的文件夹中然后删除旧的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"

1 个答案:

答案 0 :(得分:1)

我想你想要这样的东西

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

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