Последние новости:

Поиск по сайту:

Чрезмерная скромность есть не что иное, как скрытая гордость (А. Шенье).

Утилиты сжатия в Linux4 мин для чтения

FavoriteLoadingДобавить в избранное
18.03.2017
Утилиты командной сжатия в Linux

1. Zip

Ниже перечислены основные утилиты, которые доступны для сжатия файлов

Формат для архивирования файлов: zip <filename> <source_files>

 

[root@destroyer zip_test]# zip test.zip mytest1.txt mytest2.txt mytest3.txt
adding: mytest1.txt (deflated 92%)
adding: mytest2.txt (deflated 92%)
adding: mytest3.txt (deflated 92%)
[root@destroyer zip_test]# ll
total 16
-rw-r–r–. 1 root root 221 Mar 19 12:12 mytest1.txt
-rw-r–r–. 1 root root 221 Mar 19 12:12 mytest2.txt
-rw-r–r–. 1 root root 221 Mar 19 12:13 mytest3.txt
-rw-r–r–. 1 root root 511 Mar 19 12:19 test.zip
[root@destroyer zip_test]#

 

Формат для распаковки файлов: unzip <filename>.zip

 

[root@destroyer zip_test]# ll
total 16
-rw-r–r–. 1 root root 221 Mar 19 12:12 mytest1.txt
-rw-r–r–. 1 root root 221 Mar 19 12:12 mytest2.txt
-rw-r–r–. 1 root root 221 Mar 19 12:13 mytest3.txt
-rw-r–r–. 1 root root 511 Mar 19 12:19 test.zip
[root@destroyer zip_test]# rm -f *.txt

 

Примечание: Удаление текстовых файлов для лучшего понимания темы, пожалуйста, не выполняйте эту команду в вашей среде.

[root@destroyer zip_test]# ll
total 4
-rw-r–r–. 1 root root 511 Mar 19 12:10 test.zip
[root@destroyer zip_test]# unzip test.zip
Archive: test.zip
inflating: mytest1.txt
inflating: mytest2.txt
inflating: mytest3.txt
[root@destroyer zip_test]# ll
total 16
-rw-r–r–. 1 root root 221 Mar 19 12:12 mytest1.txt
-rw-r–r–. 1 root root 221 Mar 19 12:12 mytest2.txt
-rw-r–r–. 1 root root 221 Mar 19 12:13 mytest3.txt
-rw-r–r–. 1 root root 511 Mar 19 12:19 test.zip
[root@destroyer zip_test]#

 

2. gzip

Формат для архивирования файлов: gzip

[root@destroyer zip_test]# ll
total 12
-rw-r–r–. 1 root root 221 Mar 19 12:12 mytest1.txt
-rw-r–r–. 1 root root 221 Mar 19 12:12 mytest2.txt
-rw-r–r–. 1 root root 221 Mar 19 12:13 mytest3.txt
[root@destroyer zip_test]# gzip mytest1.txt mytest2.txt mytest3.txt
[root@destroyer zip_test]# ll
total 12
-rw-r–r–. 1 root root 45 Mar 19 12:12 mytest1.txt.gz
-rw-r–r–. 1 root root 45 Mar 19 12:12 mytest2.txt.gz
-rw-r–r–. 1 root root 45 Mar 19 12:13 mytest3.txt.gz
[root@destroyer zip_test]#

 

Формат для файлов GUNzipping: gunzip .gz

[root@destroyer zip_test]# ll
total 12
-rw-r–r–. 1 root root 45 Mar 19 12:12 mytest1.txt.gz
-rw-r–r–. 1 root root 45 Mar 19 12:12 mytest2.txt.gz
-rw-r–r–. 1 root root 45 Mar 19 12:13 mytest3.txt.gz
[root@destroyer zip_test]# gunzip mytest1.txt.gz
[root@destroyer zip_test]# ll
total 12
-rw-r–r–. 1 root root 221 Mar 19 12:12 mytest1.txt
-rw-r–r–. 1 root root 45 Mar 19 12:12 mytest2.txt.gz
-rw-r–r–. 1 root root 45 Mar 19 12:13 mytest3.txt.gz
[root@destroyer zip_test]# gunzip mytest2.txt.gz mytest3.txt.gz
[root@destroyer zip_test]# ll
total 12
-rw-r–r–. 1 root root 221 Mar 19 12:12 mytest1.txt
-rw-r–r–. 1 root root 221 Mar 19 12:12 mytest2.txt
-rw-r–r–. 1 root root 221 Mar 19 12:13 mytest3.txt
[root@destroyer zip_test]#

 

Читать  Как установить и использовать EasyOCR в Linux

3.  bzip2

Формат для архивирования файлов с помощью: bzip2

[root@destroyer zip_test]# ll
total 12
-rw-r–r–. 1 root root 221 Mar 19 12:12 mytest1.txt
-rw-r–r–. 1 root root 221 Mar 19 12:12 mytest2.txt
-rw-r–r–. 1 root root 221 Mar 19 12:13 mytest3.txt
[root@destroyer zip_test]# bzip2 mytest1.txt mytest2.txt mytest3.txt
[root@destroyer zip_test]# ll
total 12
-rw-r–r–. 1 root root 66 Mar 19 12:12 mytest1.txt.bz2
-rw-r–r–. 1 root root 66 Mar 19 12:12 mytest2.txt.bz2
-rw-r–r–. 1 root root 66 Mar 19 12:13 mytest3.txt.bz2

 

Формат BUNzipping файлов: bunzip2 .bz2

[root@destroyer zip_test]# ll
total 12
-rw-r–r–. 1 root root 66 Mar 19 12:12 mytest1.txt.bz2
-rw-r–r–. 1 root root 66 Mar 19 12:12 mytest2.txt.bz2
-rw-r–r–. 1 root root 66 Mar 19 12:13 mytest3.txt.bz2
[root@destroyer zip_test]# bunzip2 mytest1.txt.bz2
[root@destroyer zip_test]# ll
total 12
-rw-r–r–. 1 root root 221 Mar 19 12:12 mytest1.txt
-rw-r–r–. 1 root root 66 Mar 19 12:12 mytest2.txt.bz2
-rw-r–r–. 1 root root 66 Mar 19 12:13 mytest3.txt.bz2
[root@destroyer zip_test]# bunzip2 mytest2.txt.bz2 mytest3.txt.bz2
[root@destroyer zip_test]# ll
total 12
-rw-r–r–. 1 root root 221 Mar 19 12:12 mytest1.txt
-rw-r–r–. 1 root root 221 Mar 19 12:12 mytest2.txt
-rw-r–r–. 1 root root 221 Mar 19 12:13 mytest3.txt
[root@destroyer zip_test]#

 

4. Команда Tar:

Формат для ведения tar из файлов: tar -cvf .tar

[root@destroyer zip_test]# ll
total 12
-rw-r–r–. 1 root root 221 Mar 19 12:12 mytest1.txt
-rw-r–r–. 1 root root 221 Mar 19 12:12 mytest2.txt
-rw-r–r–. 1 root root 221 Mar 19 12:13 mytest3.txt
[root@destroyer zip_test]# tar -cvf test.tar mytest1.txt mytest2.txt mytest3.txt
mytest1.txt
mytest2.txt
mytest3.txt
[root@destroyer zip_test]# ll
total 24
-rw-r–r–. 1 root root 221 Mar 19 12:12 mytest1.txt
-rw-r–r–. 1 root root 221 Mar 19 12:12 mytest2.txt
-rw-r–r–. 1 root root 221 Mar 19 12:13 mytest3.txt
-rw-r–r–. 1 root root 10240 Mar 19 12:59 test.tar
[root@destroyer zip_test]#

 

Формат для распаковки файлов: tar -xvf

[root@destroyer zip_test]# ll
total 24
-rw-r–r–. 1 root root 221 Mar 19 12:12 mytest1.txt
-rw-r–r–. 1 root root 221 Mar 19 12:12 mytest2.txt
-rw-r–r–. 1 root root 221 Mar 19 12:13 mytest3.txt
-rw-r–r–. 1 root root 10240 Mar 19 12:59 test.tar
[root@destroyer zip_test]# rm -f *.txt

 

Читать  Как я могу увидеть изменения каталога в Python?

Примечание: удаление файлов txt для лучшего понимания темы, прошу не выполнять эту команду в вашей среде.

[root@destroyer zip_test]# ll
total 12
-rw-r–r–. 1 root root 10240 Mar 19 12:59 test.tar
[root@destroyer zip_test]#
[root@destroyer zip_test]# tar -xvf test.tar
mytest1.txt
mytest2.txt
mytest3.txt
[root@destroyer zip_test]# ll
total 24
-rw-r–r–. 1 root root 221 Mar 19 12:12 mytest1.txt
-rw-r–r–. 1 root root 221 Mar 19 12:12 mytest2.txt
-rw-r–r–. 1 root root 221 Mar 19 12:13 mytest3.txt
-rw-r–r–. 1 root root 10240 Mar 19 12:59 test.tar
[root@destroyer zip_test]#

 

[root@destroyer zip_test]# tar -tvf test.tar
-rw-r–r– root/root 221 2015-06-14 09:12 mytest1.txt
-rw-r–r– root/root 221 2015-06-14 09:12 mytest2.txt
-rw-r–r– root/root 221 2015-06-14 09:13 mytest3.txt
[root@destroyer zip_test]#

 

Утилиты командной сжатия в Linux

Если вы нашли ошибку, пожалуйста, выделите фрагмент текста и нажмите Ctrl+Enter.

1 Звезда2 Звезды3 Звезды4 Звезды5 Звезд (1 оценок, среднее: 5,00 из 5)
Загрузка...
Поделиться в соц. сетях:

0 0 голоса
Рейтинг статьи
Подписаться
Уведомить о
guest

**ссылки nofollow

0 комментариев
Межтекстовые Отзывы
Посмотреть все комментарии

Это может быть вам интересно

Статьи партнеров:

Рекомендуемое
Вы пытаетесь исправить ошибку разрешения для файлов и папок в…
0
Оставьте комментарий! Напишите, что думаете по поводу статьи.x

Сообщить об опечатке

Текст, который будет отправлен нашим редакторам:

Заполните форму и наш менеджер перезвонит Вам в самое ближайшее время!

badge
Обратный звонок 1
Отправить

Спасибо! Ваша заявка принята

close

Спасибо! Ваша заявка принята

close