tech:shell_gnu_tar_-_commande_tar
Différences
Ci-dessous, les différences entre deux révisions de la page.
| Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
| tech:shell_gnu_tar_-_commande_tar [2025/03/26 14:59] – Jean-Baptiste | tech:shell_gnu_tar_-_commande_tar [2026/03/05 10:41] (Version actuelle) – Jean-Baptiste | ||
|---|---|---|---|
| Ligne 1: | Ligne 1: | ||
| + | < | ||
| + | {{tag> | ||
| + | |||
| + | # Shell GNU tar - Commande tar | ||
| + | |||
| + | |||
| + | ~~~bash | ||
| + | man tar | ||
| + | info tar | ||
| + | ~~~ | ||
| + | |||
| + | |||
| + | ## Exemples / options | ||
| + | |||
| + | ### Inclusion / Exclusion | ||
| + | |||
| + | ~~~bash | ||
| + | tar --exclude=/ | ||
| + | ~~~ | ||
| + | |||
| + | ~~~bash | ||
| + | tar --exclude=' | ||
| + | ~~~ | ||
| + | |||
| + | |||
| + | Spécifier le chemin racine - éviter ' | ||
| + | |||
| + | Utiliser l' | ||
| + | ~~~bash | ||
| + | tar czf ~/ | ||
| + | ~~~ | ||
| + | |||
| + | |||
| + | Archiver des fichiers cachés (dot files) | ||
| + | ~~~bash | ||
| + | tar cvjf archive.tar.bz2 --exclude .. --exclude . .* | ||
| + | ~~~ | ||
| + | |||
| + | |||
| + | #### Dot dir dossier point à la racine | ||
| + | |||
| + | ##### Creation d' | ||
| + | |||
| + | Dossier " | ||
| + | ~~~ | ||
| + | $ tar czvf ../ | ||
| + | ./ | ||
| + | ./ | ||
| + | ./ | ||
| + | |||
| + | $ tar czvf ../ | ||
| + | check_routerHA.sh | ||
| + | plop.tar.gz | ||
| + | |||
| + | # Ou encore | ||
| + | $ tar czvf ../ | ||
| + | |||
| + | # Ou | ||
| + | #find . -print0 | ||
| + | $ find . -printf " | ||
| + | |||
| + | # Autre | ||
| + | # find -mindepth 1 . | ||
| + | ~~~ | ||
| + | |||
| + | |||
| + | ##### Extraction d' | ||
| + | ~~~bash | ||
| + | tar --strip-components 1 -xvf plop.tar.gz | ||
| + | ~~~ | ||
| + | |||
| + | |||
| + | |||
| + | ### Droits / permissions / owner | ||
| + | |||
| + | GNU tar allows you not to preserve the owner and permissions. | ||
| + | ~~~bash | ||
| + | tar -c -f archive.tar --owner=0 --group=0 --no-same-owner --no-same-permissions | ||
| + | ~~~ | ||
| + | |||
| + | |||
| + | |||
| + | ### Compression | ||
| + | |||
| + | ~~~ | ||
| + | gzip: warning: GZIP environment variable is deprecated; use an alias or script | ||
| + | ~~~ | ||
| + | |||
| + | L' | ||
| + | ~~~bash | ||
| + | GZIP=-9 tar -zcf ... files to compress ... | ||
| + | ~~~ | ||
| + | |||
| + | Devient | ||
| + | ~~~bash | ||
| + | tar -I 'gzip -9' -cf ... files to compress | ||
| + | ~~~ | ||
| + | |||
| + | |||
| + | |||
| + | ## Autres outils | ||
| + | |||
| + | Voir aussi | ||
| + | * cpio | ||
| + | * archivemount (et avfs / mountavfs) | ||
| + | |||
| + | |||
| + | |||
| + | ### pkgdiff / tardiff (html diff was produced by rfcdiff) | ||
| + | |||
| + | pkgdiff pour faire un diff de deux fichiers tar | ||
| + | ~~~bash | ||
| + | pkgdiff -hide-unchanged nagios-3.0_v001.tgz nagios-3.0_v002.tgz | ||
| + | ~~~ | ||
| + | |||
| + | **pkgdiff** se base sur l' | ||
| + | ~~~bash | ||
| + | # Ne pas faire : | ||
| + | pkgdiff -hide-unchanged plop.tgz plop.tgz2 | ||
| + | |||
| + | # Mais faire : | ||
| + | mv plop.tgz2 plop2.tgz | ||
| + | pkgdiff -hide-unchanged plop.tgz plop2.tgz | ||
| + | ~~~ | ||
| + | |||
| + | Cela génére un rapport HTML. | ||
| + | |||
| + | Il y a aussi tardiff **mais il bug** | ||
| + | ~~~bash | ||
| + | tardiff nagios-3.0_v001.tgz nagios-3.0_v002.tgz | ||
| + | |||
| + | # BUG: L' | ||
| + | # 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 à | ||
| + | ~~~bash | ||
| + | diff <(tar tf nagios-3.0_v001.tgz | sort ) <(tar tf nagios-3.0_v002.tgz | sort ) | ||
| + | |||
| + | # Pour les droits, propriétaire, | ||
| + | diff <(tar tvf nagios-3.0_v001.tgz | sort ) <(tar tvf nagios-3.0_v002.tgz | sort ) | ||
| + | ~~~ | ||
| + | |||
| + | |||
| + | ## Autres | ||
| + | |||
| + | Voir : | ||
| + | * '' | ||
| + | * '' | ||
| + | |||
| + | |||
| + | |||
| + | |||
| + | |||
| + | ## Pb | ||
| + | |||
| + | |||
| + | |||
| + | |||
| + | ### Erreur Cannot hard link to | ||
| + | |||
| + | ~~~ | ||
| + | $ tar -xzf Maildir.tar.gz Maildir/ | ||
| + | tar: Maildir/ | ||
| + | tar: Exiting with failure status due to previous errors | ||
| + | ~~~ | ||
| + | |||
| + | Monter une archive tar.gz | ||
| + | ~~~bash | ||
| + | sudo apt-get install archivemount | ||
| + | mkdir ~/mnt | ||
| + | archivemount Maildir.tar.gz ~/mnt/ | ||
| + | rsync -axv ~/ | ||
| + | fusermount -u ~/mnt | ||
| + | ~~~ | ||
| + | |||
| + | |||
| + | |||
