带排除功能的 Linux tar 命令

2 linux tar exclude

我想创建一个文件夹的 tar 文件,但该文件夹包含一些 tar.gz 文件,如 abc.tar.gz、pqr.tar.gz 我不想包含这些文件,那么如何在制作 tar 时排除这些文件

小智 5

 --exclude=PATTERN
      When performing operations, `tar' will skip files that match
      PATTERN.
Run Code Online (Sandbox Code Playgroud)
--exclude="*.tar.gz"
Run Code Online (Sandbox Code Playgroud)
 --exclude-from=FILE
 -X FILE
      Similar to --exclude, except `tar' will use the list of patterns
      in the file FILE.
Run Code Online (Sandbox Code Playgroud)
--exclude-from="File.txt"
Run Code Online (Sandbox Code Playgroud)

文件.txt

abc.tar.gz
prq.tar.gz
Run Code Online (Sandbox Code Playgroud)