Skip to content

Instantly share code, notes, and snippets.

@winse
Created June 20, 2014 05:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save winse/6e60916d4ac369cf9430 to your computer and use it in GitHub Desktop.
Save winse/6e60916d4ac369cf9430 to your computer and use it in GitHub Desktop.
tar解压(过滤)部分文件: --exclude=XXX, XXX
[hadoop@localhost tmp]$ tar zcvf test.tar.gz .
./
./c/
./c/1/
./c/1/2/
./b/
./b/1/
./b/1/2/
./a/
./a/1/
./a/1/2/
[hadoop@localhost tmp]$ ls
a b c test.tar.gz
[hadoop@localhost tmp]$ rm -rf ?
[hadoop@localhost tmp]$ ls -l
total 4
-rw-rw-r--. 1 hadoop hadoop 195 Jun 20 21:04 test.tar.gz
[hadoop@localhost tmp]$ tar zxvf test.tar.gz --exclude=c/1
./
./c/
./b/
./b/1/
./b/1/2/
./a/
./a/1/
./a/1/2/
[hadoop@localhost tmp]$ rm -rf ?
[hadoop@localhost tmp]$ ls -l
total 4
-rw-rw-r--. 1 hadoop hadoop 195 Jun 20 21:04 test.tar.gz
[hadoop@localhost tmp]$ tar zxvf test.tar.gz a
tar: a: Not found in archive
tar: Exiting with failure status due to previous errors
[hadoop@localhost tmp]$ tar zxvf test.tar.gz ./a
./a/
./a/1/
./a/1/2/
[hadoop@localhost tmp]$
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment