tar
tar cf archive.tar dossier
tar tf archive.tar
gzip archive.tar
tar czf archive.tar.gz dossier
Il est possible d’indiquer à la commande tar
un dossier
différent du répertoire courant pour réaliser ses opérations.
Pour les exemples suivants, nous allons créer une arborescence de test:
mkdir -p data/info
echo "Informations" > data/info/fichier1.txt
echo "# Présentation" > data/README.md
Ce qui donne l’arborescence suivante:
$ tree
.
└── data
├── info
│ └── fichier1.txt
└── README.md
data
et de son contenutar czf data.tar.gz data
data.tar.gz
La commande tar tf data.tar.gz
donne la sortie
suivante:
data/
data/info/
data/info/fichier1.txt
data/README.md
Ceci montre que le dossier data
a été inclus au moment
de la création de l’archive.
Bien noter le .
à la fin de la commande:
tar czf donnees.tar.gz -C data .
La commande tar tf donnees.tar.gz
donne la sortie
suivante:
./
./info/
./info/fichier1.txt
./README.md
L’option -C
suivie du chemin cible permet de
décompresser dans un dossier différent du dossier courant:
mkdir chemin/vers/dossier_cible
tar xf donneez.tar.gz -C chemin/vers/dossier_cible
Archivage du dossier /usr/bin
tar czf usr-bin.tar.gz /usr/bin
L’archive contient dans ce cas l’arborescence complète
usr/bin
:
$ tar tf usr-bin.tar.gz | head -3
usr/bin/
usr/bin/rev
usr/bin/diff3
Archivage du dossier bin
situé dans
/usr
tar czf bin.tar.gz -C /usr bin
Dans ce cas, seul la partie bin
de l’arborescence est
stockée:
$ tar tf usr-bin.tar.gz | head -3
bin/
bin/rev
bin/diff3
cd informatique
tar czf informatique.tar.gz mac/ linux/ windows/
autre solution:
tar czf informatique.tar.gz -C informatique .
/tmp
tar cjf archive.tar.bz2 dossier
Le J est majuscule !
tar cJf archive.tar.xz dossier
cat > fichier <<EOF
ENDNOTES:
(1) "Waskstone", see Adventure XXXV, note 2.
(2) "Fall". The word "not", translated here "fall", means
really 'disaster', but as this word is not in keeping with
the style, "fall" has been chosen as preferable to 'need',
used by some translators. The MS. C has here "liet" instead
of "not" of A and B.
(3) The "Nibelungenlied" is continued by the so-called "Klage",
a poem written in short rhyming couplets. As the name
indicates, it describes the lamentations of the survivors
over the dead. The praises of each warrior are sung and a
messenger dispatched to acquaint Gorelind, Uta, and Brunhild
with the sad end of their kinsmen. It closes with
Dietrich's departure from Etzel's court and his return home.
Although in one sense a continuation of our poem, the
"Klage" is an independent work of no great merit, being
excessively tedious with its constant repetitions. A
reprint and a full account of it will be found in Piper's
edition of our poem, vol. I.
EOF
gzip fichier
zcat fichier.gz | less