Outils pour utilisateurs

Outils du site


tech:shell_gnu_tar_-_commande_tar

Ceci est une ancienne révision du document !


Shell GNU tar - Commande tar

man tar
info tar

Exemples / options

Exclusion

tar --exclude=/data/sub1 --exclude=/data/sub2 --exclude=/data/sub3 --exclude=/data/sub4 -cf /home/_data.tar /data 
tar --exclude='*/.git/*' -cf /home/_data.tar /data 

Spécifier le chemin racine - éviter 'cd'

Utiliser l'option -C pour indiquer le chemin

tar czf ~/tmp/nagios.tgz -C ~/tmp/ --exclude='.git' --owner=1013 --group=250 nagios/

Autres outils

Voir aussi

  • cpio
  • archivemount (et avfs / mountavfs)

pkgdiff / tardiff

pkgdiff pour faire un diff de deux fichiers tar

pkgdiff -hide-unchanged nagios-3.0_v001.tgz nagios-3.0_v002.tgz

pkgdiff se base sur l'extention du fichier

# Ne pas faire :
pkgdiff -hide-unchanged plop.tgz plop.tgz2
 
# Mais faire :
pkgdiff -hide-unchanged plop.tgz plop2.tgz

Cela génére un rapport HTML.

Il y a aussi tardiff mais il bug

tardiff nagios-3.0_v001.tgz nagios-3.0_v002.tgz
 
# BUG: L'option ''-m'' ne fonctionne pas
# C'est comme si cette option était ignorée
# tardiff affiche bien les fichiers ajoutés mais pas les fichiers modifiés
tardiff -m nagios-3.0_v001.tgz nagios-3.0_v002.tgz

Cela revient à

diff <(tar tf nagios-3.0_v001.tgz | sort )  <(tar tf nagios-3.0_v002.tgz | sort )
 
# Pour les droits, propriétaire, date
diff <(tar tvf nagios-3.0_v001.tgz | sort )  <(tar tvf nagios-3.0_v002.tgz | sort )

Autres

Voir :

  • --strip-components=NUMBER
  • --strip

Pb

$ tar -xzf Maildir.tar.gz Maildir/.Sent/
tar: Maildir/.Sent/cur/1665228871.M836500P20407.vps788223,S=3786957,W=3836179\:2,S: Cannot hard link to ‘Maildir/.Trash/cur/1665228871.M836500P20407.vps788223,S=3786957,W=3836179:2,S’: No such file or directory
tar: Exiting with failure status due to previous errors

Monter une archive tar.gz

sudo apt-get install archivemount
mkdir ~/mnt
archivemount Maildir.tar.gz ~/mnt/
rsync -axv ~/mnt/Maildir/.Sent/ Maildir/.Sent/
fusermount -u ~/mnt
tech/shell_gnu_tar_-_commande_tar.1742983222.txt.gz · Dernière modification : de Jean-Baptiste

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki