在我的代码中,我创建了 2 个文件夹。一个作为存放存档的文件夹,另一个是存档内的一个文件夹,其中包含 tar、压缩和 Jar 完成。
为什么当它到达 jar 命令时它说 .tar.Z 没有这样的文件或目录??
#!/bin/bash
echo "++++++++++++++++++++++++++"
#The script should prompt the user for the name of a folder to archive.
echo "Please enter the name of a folder to archive"
read file1
echo "++++++++++++++++++++++++++"
#The script should prompt the user for the name of a folder to store the archives in.
echo "Please enter a foldername to store archives in"
read file2
echo "++++++++++++++++++++++++++"
#The script should create the folder input in step 2.
mkdir $file2
cd $file2
mkdir $file1
echo "Created Files"
echo "++++++++++++++++++++++++++"
#The script should run the command to TAR all of the files in the folder specified in step 1 to a tar archive called [folder name].tar in the archive folder specified in step 2.
tar cf $file1.tar $file1
echo "++++++++++++++++++++++++++"
#The script should compress the TAR file you created in step 4 to a [folder name].tar.Z in the archive folder specified in step 2.
compress -v $file1.tar
echo "++++++++++++++++++++++++++"
#The script should run the command to JAR all of the files in the folder specified in step 1 to a jar archive called [folder name].jar in the archive folder specified in step 2.
jar cf $ffile1.jar $ffile1.tar.Z
回声“++++++++++++++++++++++++++++”
您编写 $ffile1.tar.Z
而不是 $file1.tar.Z
。
我是一名优秀的程序员,十分优秀!