Linux tar 命令忽略权限被拒绝的文件

Linux tar command ignore files which permission denied

我在 tar 目录时遇到问题。另一个用户创建的子目录中有一个备份文件,不允许其他用户读取。所以我的 tar 命令失败了。

我的问题是:我可以忽略这个文件(其实这个文件并不重要)和tar其余的files/directories吗?

来自 Gnu tar manual:

To avoid operating on files whose names match a particular pattern, use the --exclude' or--exclude-from' options.

`--exclude=pattern' Causes tar to ignore files that match the pattern.

所以你可以使用

tar --exclude='your_file_to_exclude'