Wednesday, October 17, 2012

tar quick ref

List the files from tar:
------------------------

[mandy@mandy mpande]$ tar -tvf mp.tar
-rw-r----- mandy/mandy 12 2012-08-30 05:13:06 20120830000001.txt
-rw-r----- mandy/mandy 12 2012-08-30 05:13:15 20120830000002
-rw-r----- mandy/mandy 12 2012-08-30 05:13:25 20120830000003.txt
-rw-r----- mandy/mandy 12 2012-08-30 05:11:32 3
-rw-r----- mandy/mandy 12 2012-08-30 05:11:34 4
-rw-r----- mandy/mandy 12 2012-08-30 05:11:37 5

List only *2012* files from tar:
--------------------------------

[mandy@mandy mpande]$ tar -tvf mp.tar --wildcards --no-anchored '*2012*'
-rw-r----- mandy/mandy 12 2012-08-30 05:13:06 20120830000001.txt
-rw-r----- mandy/mandy 12 2012-08-30 05:13:15 20120830000002
-rw-r----- mandy/mandy 12 2012-08-30 05:13:25 20120830000003.txt

Extract files with *2012* from tar:
-----------------------------------

[mandy@mandy mpande]$ tar -xvf mp.tar --wildcards --no-anchored '*2012*'
20120830000001.txt
20120830000002
20120830000003.txt

List files excluding certain pattern:
-------------------------------------

[mandy@mandy mpande]$ tar -tvf mp.tar --exclude *2012*
-rw-r----- mandy/mandy 12 2012-08-30 05:11:32 3
-rw-r----- mandy/mandy 12 2012-08-30 05:11:34 4
-rw-r----- mandy/mandy 12 2012-08-30 05:11:37 5

Extract files excluding certain pattern:
----------------------------------------

[mandy@mandy mpande]$ tar -xvf mp.tar --exclude *2012*
3
4
5

No comments:

Post a Comment