Syntaxe
tar [OPTIONS] [ARCHIVE] [FICHIERS...]
Options principales
| Option | Description |
|---|
-c | Créer une nouvelle archive |
-x | Extraire le contenu d'une archive |
-z | Compresser/décompressér avec gzip |
-f | Spécifier le nom du fichier archive |
Exemples
Créer une archive compressée d'un projet
$ tar -czf backup-2024-05-08.tar.gz ./src/ ./package.json ./tsconfig.json
$ ls -lh backup-2024-05-08.tar.gz
-rw-r--r-- 1 mouctar mouctar 4.2M mai 8 10:30 backup-2024-05-08.tar.gz
Extraire une archive dans un répertoire cible
$ tar -xzf release-v2.1.0.tar.gz -C /opt/app/
$ ls /opt/app/
dist/ node_modules/ package.json ecosystem.config.js
Lister le contenu sans extraire
$ tar -tzf backup-2024-05-08.tar.gz
./src/
./src/index.ts
./src/app.ts
./src/utils/helpers.ts
./package.json
./tsconfig.json