|
grattage gratuit
loterie gratuite
casino gratuit
quizz gratuit
pari gratuit
jeu de pronostic
tirage au sort
jeux de hasard
tombola gratuite
jeux en flash
jeu en réseau
jeu de stratégie
jeux TV
multi jeux
concours gratuit
|
Compression
avec zip
Archivage avec tar
Compression
avec bzip2
Compression avec tar
Compression
avec lha
1) Compression
en un seul fichier
Plutôt qu'un long discours, je préfère
l'exemple ( les exemples) qui est ( sont )
plus parlant :
Archivage avec
cpio :
exemple : Dans
une fenêtre xterm ou en mode console
[cr@localhost fichier]# ls
-l
total 12
-rw-r--r-- 1 cr
cr
2044 aoû 17 08:53 Focus.java
-rw-r--r-- 1 cr
cr
2666 aoû 17 08:53 Lens.java
-rw-r--r-- 1 cr
cr
2239 aoû 17 08:53 Points.java
[cr@localhost fichier]# ls
*.java |cpio
-ov>archive
14 blocks
[cr@localhost fichier]# ls
-l
total 20
-rw-r--r-- 1 cr
cr
2044 aoû 17 08:53 Focus.java
-rw-r--r-- 1 cr
cr
2666 aoû 17 08:53 Lens.java
-rw-r--r-- 1 cr
cr
2239 aoû 17 08:53 Points.java
-rw-r--r-- 1 cr
cr
7168 aoû 17 08:57 archive
[cr@localhost fichier]# rm
*.java
[cr@localhost fichier]# ls
-l
total 8
-rw-r--r-- 1 cr
cr
7168 aoû 17 08:57 archive
[cr@localhost fichier]# cpio
-i <archive
14 blocks
[cr@localhost fichier]# ls
-l
total 20
-rw-r--r-- 1 cr
cr
2044 aoû 17 08:58 Focus.java
-rw-r--r-- 1 cr
cr
2666 aoû 17 08:58 Lens.java
-rw-r--r-- 1 cr
cr
2239 aoû 17 08:58 Points.java
-rw-r--r-- 1 cr
cr
7168 aoû 17 08:57 archive
[cr@localhost fichier]#
Si on prend un répertoire contenant les fichiers
suivants :
[cr@localhost /cr]# cd /usr/local/progs/java
[cr@localhost java]# ls
-l
total 84
drwxr-xr-x 9 cr
cr
4096 mar 2 09:53 DeveloperX2/
drwxr-xr-x 9 cr
cr
4096 jui 18 23:10 JChemPaint/
drwxr-xr-x 3 cr
cr
4096 jui 18 23:18 JavaShop/
drwxr-xr-x 6 cr
cr
4096 déc 4 1996 Kanchenjunga/
drwx------ 2 cr cr
4096 mar 2 16:49 Lentille/
drwxr-xr-x 4 cr
cr
4096 fév 12 1999 MoleculeViewer/
drwxr-xr-x 2 cr
cr
4096 fév 4 2000 Surfacer/
drwx------ 2 cr cr
4096 fév 23 12:02 bean/
drwxr-xr-x 2 cr
cr
4096 oct 14 1999 examples/
drwx------ 2 cr
cr
4096 déc 6 1999 exception/
drwx------ 2 cr cr
4096 déc 6 1999 hellouser/
drwx------ 2 cr cr
4096 déc 6 1999 helloworld/
drwxr-xr-x 4 cr
cr
4096 fév 20 19:15 jai/
drwxr-xr-x 5 cr
cr
4096 avr 19 1980 javacheck/
drwxr-xr-x 3 cr
cr
4096 mai 21 1999 javadoc/
drwx------ 2 cr cr
4096 aoû 7 11:22 jsp/
drwxr-xr-x
3 cr cr
4096 aoû 8 00:31 projetdb/
drwxr-xr-x 3 cr
cr
4096 jui 4 17:05 projetjavadb/
drwxr-xr-x 2 cr
cr
4096 nov 2 1998 sun/
drwxr-xr-x 6 cr
cr
4096 fév 20 19:15 tutor/
drwxr-sr-x 4 cr
cr
4096 mai 21 1999 xml-tr2/
[cr@localhost java]#
Le contenu du répertoire
projetdb peut être visualisé ave la commande
ls projetdb
[cr@localhost java]# ls
projetdb/
ConnectDB$1.class
ListDialog$1.class
TableExample.javaTreeTableModel.java*
ConnectDB.class
ListDialog$2.classTableMap.classTreeTableModelAdapter.java*
ConnectDB.java*ListDialog$3.class
TableMap.java*images/
DataBaseInternalFrame.class ListDialog$4.class
TableSorter$1.class showDataBase$1.class
DataBaseInternalFrame.java*ListDialog$5.class
TableSorter.class
showDataBase$2.class
DynamicTree.class
ListDialog.class
TableSorter.java*
showDataBase$3.class
DynamicTree.java*ListDialog.java*
ToolBarDemo2$1.class showDataBase$4.class
InternalFrameDemo$1.class MyInternalFrame.class
ToolBarDemo2$2.class showDataBase$5.class
InternalFrameDemo$2.class MyInternalFrame.java*
ToolBarDemo2$3.class showDataBase$6.class
InternalFrameDemo.classOldJTable.classToolBarDemo2$4.classshowDataBase.class
InternalFrameDemo.java*OldJTable.java*ToolBarDemo2$5.classshowDataBase.java*
JDBCAdapter.class
SelectCustumizer.java ToolBarDemo2.class
sqlTextarea.java*
JDBCAdapter.java*
TabbedPane.class
ToolBarDemo2.java
vectorJLabel.class
JTreeTable.java*
TabbedPane.java*
TreeTableModel.class vectorJLabel.java*
[cr@localhost java]#
Pour comprimer le répertoire projetdb,
il faut se placer au dessus de la racine dans une
fenêtre xterm :
Compression
avec zip
Les options :
zip [-options] [-b path] [-t mmddyyyy] [-n suffixes] [zipfile
list] [-xi list]
The default action is to add or replace zipfile entries
from list, which can include the special name - to compress
standard input. If zipfile and list are omitted, zip compresses
stdin to stdout.
-f freshen: only changed files
-u update: only changed or new files
-d delete entries in zipfile
-m move into zipfile (delete files)
-r recurse into directories
-j junk (don't record) directory names
-0 store only-l
convert LF to CR LF (-ll CR LF to LF)
-1 compress faster-9
compress better
-q quiet operation-v
verbose operation/print version info
-c add one-line comments
-z add zipfile comment
-@ read names from stdin
-o make zipfile as old as latest entry
-x exclude the following names
-i include only the following
names
-F fix zipfile (-FF try harder)
-D do not add directory entries
-A adjust self-extracting exe
-J junk zipfile prefix (unzipsfx)
-T test zipfile integrity
-X eXclude eXtra file attributes
-y store symbolic links as the link
instead of the referenced file
-R PKZIP recursion (see manual)
-h show this help
-n don't compress these suffixes
exemple :
[cr@localhost java]# zip
projetdb.zip -r projetdb/
[cr@localhost java]# ls
-l projetdb.zip
-rw-r--r-- 1 cr
cr 110315
aoû 3 19:07 projetdb.zip
Archivage
avec tar
Les options
:
GNU `tar' sauvegarde
plusieurs fichiers sur un ruban ou une archive sur disque
et peut restaurer des fichiers individuellement
d'une archive.
Usage: tar [OPTION]... [FICHIER]...
Exemples:
tar -cf archive.tar
foo bar # Création de archive.tar à
partir des fichiers foo et bar.
tar -tvf archive.tar
# Liste et affiche tous les fichiers de l'archive archive.tar.
tar -xf archive.tar
# Extrait tous les fichiers de l'archive archive.tar.
Un paramètre obligatoire
pour une option de forme longue l'est aussi pour une option
de forme courte. La même règle
s'applique à
un paramètre indiqué comme étant
optionnel.
Les options :
-t, --list
afficher le contenu d'une
archive
-x, --extract,
--get extraire les fichiers
d'une archive
-c, --create
créer une archive
-d, --diff, --comparecomparer le contenu
de l'archive et le système de fichier
-r, --append
accoler les fichiers à la fin de l'archive
-u, --update
accoler seulement les nouveaux fichiers
et ensuite les copier dans l'archive
-A, --catenateaccoler
les fichiers «tar» à l'archive
--concatenate
identique à -A
--delete
éliminer des
entrées (mais pas pour les rubans)
Exemple :
[cr@localhost java]# tar
-cf projetdb.tar projetdb
Remarque : vous pouvez écrire tar -cf projetdb.tar
projetdb ou tar
cf projetdb.tar projetdb , le moins peut-être
omis.
[cr@localhost java]# ls
-l projetdb.*
-rw-r--r-- 1 cr
cr 266240 aoû 3
19:09 projetdb.tar
-rw-r--r-- 1 cr
cr 110315 aoû 3 19:07 projetdb.zip
Le fichier projetdb.tar
peut-être comprimé avec compress , il remplacera
alors le fichier projetdb.tar par
projetdb.tar.Z
[cr@localhost java]# compress
projetdb.tar
[cr@localhost java]# ls -l projetdb.*
-rw-r--r-- 1 cr
cr 131093
aoû 8 13:31 projetdb.tar.Z
Le fichier projetdb.tar
peut-être comprimé avec bzip2, il remplacera
alors le fichier
projetdb.tar
par projetdb.tar.bz2
Compression
avec bzip2
Les options :
bzip2, a block-sorting
file compressor. Version 0.9.5d, 4-Sept-99.
usage:
bzip2 [flags and input files in any order]
-h --help
print this message
-d --decompress
force decompression
-z --compress
force compression
-k --keep
keep (don't delete) input files
-f --force
overwrite existing output
files
-t --test
test compressed
file integrity
-c --stdout
output to standard out
-q --quiet
suppress noncritical
error messages
-v --verbose
be verbose (a 2nd -v gives more)
-L --license
display software version &
license
-V --version
display software version & license
-s --small
use less memory (at most
2500k)
-1 ..
-9
set block size
to 100k .. 900k
Si vous utilisez :
- bzip2, action par défaut
la compression
- bunzip2, action par défaut la décompression.
- bzcat, action par défaut
la décompression vers la sortie.
[cr@localhost java]# bzip2
-z projetdb.tar
[cr@localhost java]# ls
-l projetdb.*
-rw-r--r-- 1 cr
cr 74596
aoû 3 19:09 projetdb.tar.bz2
-rw-r--r-- 1 cr
cr 110315 aoû 3 19:07 projetdb.zip
Compression
avec tar
[cr@localhost java]# tar
-zcf
projetdb.tar.z projetdb
L'ajout de z dans l'otption de tar , signifie qu'on comprime
en uilisant gzip.
-rw-r--r-- 1 cr
cr 78284
aoû 8 12:41 projetdb.tar.z
Vous remarquerez que j'ai
utilisé comme nom projetdb.tar.z et nom simplement
projetdb.tar, c'est pour que l'on sache
que gzip a été
utilisé (pour la décompression ).
[cr@localhost java]# tar
-Zcf
projetdb.tar.Z projetdb
L'ajout de Z dans l'otption de tar , signifie qu'on comprime
en utilisant compress.
[cr@localhost java]# ls
-l projetdb.*
-rw-r--r-- 1 cr
cr 129275 aoû 8 12:44
projetdb.tar.Z
[cr@localhost java]# tar
-Icf
projetdb.tar.bz2 projetdb
L'ajout de I dans l'otption de tar , signifie qu'on comprime
en uilisant bzip2.
[cr@localhost java]# ls -l projetdb.tar.bz2
-rw-r--r--
1 cr cr
76024 aoû
15 09:42 projetdb.tar.bz2
Compression
avec lha
Les options :
usage: lha [-]{axelvudmcp[q[num]][vnfodizg012]}[w=<dir>]
archive_file [file...]
commands:
options:
a
Add(or replace) to archive
q{num} quiet (num:quiet mode)
x,e EXtract from archive
v verbose
l,v List /
Verbose List
n not execute
u
Update newer files to archive
f force (over write at extract)
d Delete from archive
t FILES are TEXT file
m Move to archive (means 'ad')
o[56] compression method (a/u)
c re-Construct new archive
w=<dir> specify extract directory (a/u/m/x/e)
p
Print to STDOUT from archive
d delete FILES after (a/u/c)
t
Test file CRC in archive
i ignore directory path (x/e)
z files not compress (a/u)
g [Generic] format (for compatibility)
0/1/2 header level (a/u)
e TEXT code convert from/to EUC
[cr@localhost java]# lha -a projetdb.lha projetdb
[cr@localhost java]#
ls -l projetdb.*
-rw-r--r-- 1 cr
cr
266240 aoû 3 19:09
projetdb.tar
-rw-r--r-- 1 cr
cr 110315
aoû 3 19:07 projetdb.zip
-rw-r--r--
1 cr cr 104267 aoû
3 19:57 projetdb.lha
Une autre façon
plus élégante , et de combiner tar et bzip2
dans un tube ( en Français) ou pipe ( en Anglais)
[cr@localhost java]# tar
-cf projetdb.tar projetdb | bzip2 -z projetdb.tar
( pour obtenir la
barre verticale | il faut appuyer sur la touche Alt Gr
et 6 ( en même temps ).
[cr@localhost java]# ls
-l projetdb.*
-rw-r--r-- 1 cr
cr 74601
aoû 3 19:33 projetdb.tar.bz2
-rw-r--r-- 1 cr
cr 110315
aoû 3 19:07 projetdb.zip
-rw-r--r-- 1 cr
cr
104267 aoû
3 19:57 projetdb.lha
On combine l'archivage
avec tar et gzip ,pour obtenir des fichiers avec l'extension
.tar.gz
zcat est identique
à gzip même programme.
[cr@localhost java]#
tar -cf projetdb.tar projetdb |gzip -9 projetdb.tar ( -9 représente
la meilleure qualité de compression )
[cr@localhost java]#
ls -l projetdb.*
-rw-r--r-- 1 cr
cr 77389 aoû 3 19:46 projetdb.tar.gz
-rw-r--r-- 1 cr
cr 74601
aoû 3 19:33 projetdb.tar.bz2
-rw-r--r-- 1 cr
cr 110315
aoû 3 19:07 projetdb.zip
-rw-r--r-- 1 cr
cr
104267 aoû
3 19:57 projetdb.lha
On combine l'archivage
avec tar et compress ,pour obtenir un fichier avec l'extension
tar.Z
[cr@localhost java]# tar
-cf projetdb.tar projetdb |compress projetdb.tar
[cr@localhost java]# ls
-l projetdb.*
-rw-r--r-- 1 cr
cr 131093 aoû 8 12:54
projetdb.tar.Z
2 Archiver
sur plusieurs supports
Si l'archive dépasse la taille du support , exemple
d'une disquette , dans ce cas Tar possède
l'option M , qui signifie multi-volume .
tar cvM -f /mnt/floppy
projetdb/ ou tar -cvM -f
/mnt/floppy
L'option v permet
de voir défiler les fichiers copiés.
Une autre façon ,
c'est d'utiliser par exemple : tar
-zcf projetdb.tar.z projetdb
et d'utiliser ensuite split qui permet
de découper
un fichier en spécifiant la taille des paquets
ou morceaux.
[cr@localhost java]# ls
DeveloperX2
Lentille
examples jai
projetdb
xml-tr2
JChemPaint
MoleculeViewer exception
javacheck projetjavadb
JavaShop
Surfacer
hellouser javadocsun
Kanchenjunga
bean
helloworld jsp
tutor
[cr@localhost java]# tar -Icf DeveloperX2.tar.bz2 DeveloperX2
[cr@localhost java]# ls
DeveloperX2/
Lentille/
exception/ javadoc/
tutor/
DeveloperX2.tar.bz2 MoleculeViewer/
hellouser/jsp/
xml-tr2/
JChemPaint/
Surfacer/
helloworld/projetdb/
JavaShop/bean/
jai/projetjavadb/
Kanchenjunga/
examples/
javacheck/ sun/
[cr@localhost java]#
[cr@localhost java]# ls
-l DeveloperX2.tar.bz2
-rw-r--r-- 1 cr
cr 3751947 aoû 15 00:27 DeveloperX2.tar.bz2
[cr@localhost java]# split
-b 1400k DeveloperX2.tar.bz2
[cr@localhost java]# ls
DeveloperX2/
Lentille/
exception/
javadoc/
tutor/
DeveloperX2.tar.bz2 MoleculeViewer/
hellouser/jsp/xaa
JChemPaint/
Surfacer/
helloworld/ projetdb/
xab
JavaShop/
bean/
jai/
projetjavadb/ xac
Kanchenjunga/
examples/
javacheck/ sun/xml-tr2/
[cr@localhost java]#
split a
découpé DeveloperX2.tar.bz2 et cela donne trois fichiers xaa , xab et xac , il suffit de les copier
sur des disquettes.
[cr@localhost java]# ls -l xa*
-rw-r--r--
1 cr cr
1433600 aoû 15 00:29 xaa
-rw-r--r--
1 cr cr
1433600 aoû 15 00:29 xab
-rw-r--r--
1 cr cr
884747 aoû 15 00:29 xac
[cr@localhost java]#
on réassemblera
les morceau x avec la commande cat :
[cr@localhost java]# ls
DeveloperX2/
Lentille/
exception/ javadoc/
tutor/
DeveloperX2.tar.bz2
MoleculeViewer/ hellouser/
jsp/xaa
JChemPaint/Surfacer/
helloworld/ projetdb/
xab
JavaShop/
bean/jai/projetjavadb/
xac
Kanchenjunga/examples/
javacheck/ sun/xml-tr2/
[cr@localhost java]# cat xa* >> DevelopperX2bis.tar.bz2 (
ou cat xaa xab xac >> DevelopperX2bis.tar.bz2
)
[cr@localhost java]#
ls
DeveloperX2/
Surfacer/
jai/
tutor/
DeveloperX2.tar.bz2
bean/
javacheck/ xaa
JChemPaint/ DevelopperX2bis.tar.bz2
javadoc/
xab
JavaShop/
examples/
jsp/
xac
Kanchenjunga/
exception/
projetdb/
xml-tr2/
Lentille/
hellouser/
projetjavadb/
MoleculeViewer/
helloworld/
sun/
[cr@localhost java]#
Remarque : Il
ne faut pas oublier d'effacer les fichiers xaa
, xab et xac
avec la commande rm xaa
xab xac ou rm xa*
Après concatenation
les deux fichiers ont bien la même taille.
[cr@localhost java]# ls -l D*.tar*
-rw-r--r-- 1 cr
cr 3751947aoû 15 00:27 DeveloperX2.tar.bz2
-rw-r--r--
1 cr cr 3751947 aoû 15
00:39 DevelopperX2bis.tar.bz2
|
|