linuxでの圧縮解凍コマンド
6217 ワード
目次 gzip gunzip tar(パッケージ圧縮) tar(解凍解凍) zip unzip bzip2 bunzip 2 gzip解釈
構文
例
gzipはファイルを圧縮するしかなく、圧縮後、元のファイルは存在しません.
gunzip
説明する
構文
例
tar
説明する
構文
例
tar
説明する
構文
例
zip
説明する
構文
zipコマンドが見つかりません
例
gzipよりzipは元のファイルを保持し、ディレクトリを圧縮することができます.
unzip
説明する
構文
例
bzip2
説明する
構文
例
ファイルの圧縮のみ
bunzip2
説明する
構文
例
:gzip
:GUN zip
:/bin/gzip
:
:
構文
# .gz
gzip [ ]
例
#
gzip /tmp/services
[root@izm5e2q95pbpe1hh0kkwoiz ~]# ls /tmp
Aegis- php-cgi.sock
hsperfdata_root services
issue.hard systemd-private-9255c5ee9ec84f5987c1d9ba485e177e-ntpd.service-eKcnmD
issue.soft test
Japan test.txt
mysql.sock
[root@izm5e2q95pbpe1hh0kkwoiz ~]# gzip /tmp/services
[root@izm5e2q95pbpe1hh0kkwoiz ~]# ls -lh /etc/services
-rw-r--r--. 1 root root 655K Jun 7 2013 /etc/services
[root@izm5e2q95pbpe1hh0kkwoiz ~]# ls -lh /tmp/services.gz
-rw-r--r-- 1 root root 133K Nov 29 17:45 /tmp/services.gz
# 655k, 133k
gzipはファイルを圧縮するしかなく、圧縮後、元のファイルは存在しません.
gunzip
説明する
:gunzip
:GUN unzip
:/bin/gunzip
:
: .gz
構文
# .gz
gunzip [ ]
例
# services.gz
gunzip services.gz
tar
説明する
:tar
:/bin/tar
:
:
構文
tar [-zcf] [ ] [ ]
-c
-v
-f
-z
例
#
tar -czf Japan.tar.gz /tmp/Japan
tar -zcf Japan.tar.gz /tmp/Japan
# -f ,
tar -zfc Japan.tar.gz /tmp/Japan
[root@izm5e2q95pbpe1hh0kkwoiz ~]# tar -zfc Japan.tar.gz /tmp/Japan
tar: You must specify one of the `-Acdtrux' or `--test-label' options
Try `tar --help' or `tar --usage' for more information.
[root@izm5e2q95pbpe1hh0kkwoiz ~]# tar -zcf Japan.tar.gz /tmp/Japan
tar: Removing leading `/' from member names
[root@izm5e2q95pbpe1hh0kkwoiz ~]# ls
boduo Japan.tar.gz lnmp-install.log test.txt
[root@izm5e2q95pbpe1hh0kkwoiz ~]# rm Japan.tar.gz
rm: remove regular file ‘Japan.tar.gz’? y
[root@izm5e2q95pbpe1hh0kkwoiz ~]# tar -czf Japan.tar.gz /tmp/Japan
tar: Removing leading `/' from member names
[root@izm5e2q95pbpe1hh0kkwoiz ~]# ls
boduo Japan.tar.gz lnmp-install.log test.txt
tar
説明する
:tar
:/bin/tar
:
:
構文
tar [-zcf] [ ] [ ]
-x
-v
-f
-z
例
# ( )
tar -zxvf Japan.tar.gz
[root@izm5e2q95pbpe1hh0kkwoiz ~]# ls
boduo Japan.tar.gz lnmp-install.log test.txt
[root@izm5e2q95pbpe1hh0kkwoiz ~]# tar -zxvf Japan.tar.gz
tmp/Japan/
tmp/Japan/cangjing/
tmp/Japan/boduo/
tmp/Japan/longze/
[root@izm5e2q95pbpe1hh0kkwoiz ~]# ls
zip
説明する
:zip
:/usr/bin/zip
:
:
構文
# zip
zip [-r] [ ] [ ]
-r
zipコマンドが見つかりません
[root@izm5e2q95pbpe1hh0kkwoiz tmp]# zip aaa.zip test
-bash: zip: command not found
:
yum -y install zip
例
# /tmp test aaa.zip
zip aaa.zip test
[root@izm5e2q95pbpe1hh0kkwoiz tmp]# zip aaa.zip test
adding: test/ (stored 0%)
[root@izm5e2q95pbpe1hh0kkwoiz tmp]# ls
aaa.zip
Aegis-
hsperfdata_root
issue.hard
issue.soft
Japan
mysql.sock
php-cgi.sock
services
systemd-private-9255c5ee9ec84f5987c1d9ba485e177e-ntpd.service-eKcnmD
test
test.txt
# /tmp Japan
zip -r Japan.zip Japan
[root@izm5e2q95pbpe1hh0kkwoiz tmp]# zip -r Japan.zip Japan
adding: Japan/ (stored 0%)
adding: Japan/cangjing/ (stored 0%)
adding: Japan/boduo/ (stored 0%)
adding: Japan/longze/ (stored 0%)
[root@izm5e2q95pbpe1hh0kkwoiz tmp]# ls
aaa.zip
Aegis-
hsperfdata_root
issue.hard
issue.soft
Japan
Japan.zip
mysql.sock
php-cgi.sock
services
systemd-private-9255c5ee9ec84f5987c1d9ba485e177e-ntpd.service-eKcnmD
test
test.txt
gzipよりzipは元のファイルを保持し、ディレクトリを圧縮することができます.
unzip
説明する
:unzip
:/usr/bin/unzip
:
: .zip
構文
unzip [ ]
例
# aaa.zip
unzip aaa.zip
[root@izm5e2q95pbpe1hh0kkwoiz tmp]# unzip aaa.zip
Archive: aaa.zip
creating: test/
bzip2
説明する
:bzip2
:/usr/bin/bzip2
:
:
構文
# .bz2
bzip2 [-k] [ ]
-k
例
#
bzip2 -k boduo
[root@izm5e2q95pbpe1hh0kkwoiz tmp]# touch boduo
[root@izm5e2q95pbpe1hh0kkwoiz tmp]# bzip2 -k boduo
[root@izm5e2q95pbpe1hh0kkwoiz tmp]# ls
aaa.zip
Aegis-
boduo
boduo.bz2
hsperfdata_root
issue.hard
issue.soft
Japan
Japan.zip
mysql.sock
php-cgi.sock
services
systemd-private-9255c5ee9ec84f5987c1d9ba485e177e-ntpd.service-eKcnmD
test
test.txt
# .bz2
tar -cjf Japan.tar.bz2 Japan
[root@izm5e2q95pbpe1hh0kkwoiz tmp]# tar -cjf Japan.tar.bz2 Japan
[root@izm5e2q95pbpe1hh0kkwoiz tmp]# ls
aaa.zip
Aegis-
boduo
boduo.bz2
hsperfdata_root
issue.hard
issue.soft
Japan
Japan.tar.bz2
Japan.zip
mysql.sock
php-cgi.sock
services
systemd-private-9255c5ee9ec84f5987c1d9ba485e177e-ntpd.service-eKcnmD
test
test.txt
ファイルの圧縮のみ
bunzip2
説明する
:bunzip2
:/usr/bin/bunzip2
:
:
構文
bunzip2 [-k] [ ]
-k
例
#
bunzip2
[root@izm5e2q95pbpe1hh0kkwoiz tmp]# bunzip2 boduo.bz2
bunzip2: Output file boduo already exists.
[root@izm5e2q95pbpe1hh0kkwoiz tmp]# rm boduo
rm: remove regular empty file ‘boduo’? y
[root@izm5e2q95pbpe1hh0kkwoiz tmp]# bunzip2 boduo.bz2
[root@izm5e2q95pbpe1hh0kkwoiz tmp]# ls
aaa.zip
Aegis-
boduo
hsperfdata_root
issue.hard
issue.soft
Japan
Japan.tar.bz2
Japan.zip
mysql.sock
php-cgi.sock
services
systemd-private-9255c5ee9ec84f5987c1d9ba485e177e-ntpd.service-eKcnmD
test
test.txt
#
tar -xjf Japan.tar.bz2
# ,