我正在尝试使用tar
将子目录压缩/root/folder/folder{1..5}
为单个压缩存档test1.tar.bz2
。我正在使用以下命令:
tar -cvjf test1.tar.bz2 root/folder/folder{1..5}
不幸的是,这不起作用,我得到以下输出:
tar: root/folder/folder1: Cannot stat: No such file or directory
tar: root/folder/folder2: Cannot stat: No such file or directory
tar: root/folder/folder3: Cannot stat: No such file or directory
tar: root/folder/folder4: Cannot stat: No such file or directory
tar: root/folder/folder5: Cannot stat: No such file or directory
tar (child): bzip2: Cannot exec: No such file or directory
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now
答案1
您使用的是相对路径而不是绝对路径。
改变:
root/folder/folder{1..5}
太(正确的绝对路径):
/root/folder/folder{1..5}
或者(正确的相对路径):
folder/folder{1..5}
解释:
您位于根主目录 ( /root
) 内,因此相对路径将为/root
+ relative_path
,因此在您的情况下,您给出的tar
路径/root/root/folder/folder{1..5}
不存在。您可以给出正确的相对路径(省略root/
开头的 )或给出绝对路径。