A cikin labarin na gaba zamuyi la'akari da yadda zip da cire zip din fayiloli ta amfani da gzip da bzip2. Matsawa yana da matukar amfani yayin adana fayiloli masu mahimmanci ko aika manyan fayiloli akan Intanet. A yau akwai shirye-shirye da yawa don damfara da decompress fayiloli a cikin GNU / Linux.
Wani abokin aiki ya rigaya ya gaya mana game da wasu waɗannan shirye-shirye kamar rar y zip a cikin wannan shafin. A cikin wannan darasin, zamuyi la'akari da guda biyu ne kawai, kamar gzip da bzip2. Kamar yadda na fada, bari mu ga yadda za mu yi amfani da su don damfara da decompress fayiloli tare da wasu misalai a cikin Ubuntu.
Matsa fayilolin da amfani da gzip da bzip2
Shirin gzip
Gzip mai amfani ne don damfara da decompress fayiloli ta amfani da Lempel-Ziv (LZ77) tsarin ba da izini.
-
Matsa fayiloli
Don damfara fayil mai suna ubunlog.txt, maye gurbin shi tare da sigar matsawa, za mu aiwatar a cikin m (Ctrl + Alt + T):
gzip ubunlog.txt
Gzip zai maye gurbin asalin fayil ɗin da ake kira ubunlog.txt ta hanyar matsawa mai suna ubunlog.txt.gz.
Hakanan za'a iya amfani da umarnin gzip a wasu hanyoyi. Misali mai kyau shi ne cewa za mu iya ƙirƙirar sigar da aka matse na fitowar takamaiman umarni. Dubi umarnin da ke gaba.
ls -l ../../Descargas / | gzip > ubunlog.txt.gz
Umurnin da ke sama yana ƙirƙirar nau'in fasali na jerin fayiloli a cikin fayil ɗin Zazzagewa.
-
Damfara da decompress din kiyaye asalin fayil
Ta hanyar tsoho, shirin gzip zai damfara fayil ɗin da aka bayar, yana maye gurbin shi da sigar siga. Koyaya, zamu iya kiyaye ainihin fayil ɗin kuma mu rubuta sakamakon zuwa daidaitaccen fitarwa. Misali, umarni mai zuwa, damfara ubunlog.txt kuma rubuta sakamakon zuwa fitarwa.txt.gz.
gzip -c ubunlog.txt > salida.txt.gz
Haka nan, za mu iya kwancewa fayil din da aka matse tantance sunan fayil mai fitarwa:
gzip -c -d salida.txt.gz > ubunlog1.txt
Umurnin da ke sama yana buɗe fayil ɗin fitarwa.txt.gz kuma ya rubuta sakamakon zuwa fayil ɗin ubunlog1.txt. A cikin shari'o'i biyu da suka gabata, asalin fayil din ba zai share shi ba.
-
Cire fayiloli
Don kwance fayil din ubunlog.txt.gz, maye gurbin shi da asalin sigar da ba a matse shi ba, za mu yi amfani da umarni mai zuwa a cikin m (Ctrl + Alt + T):
gzip -d ubunlog.txt.gz
Hakanan zamu iya amfani da bindiga kwancewa fayiloli.
gunzip ubunlog.txt.gz
-
Duba abubuwan cikin fayilolin matsewa ba tare da rage su ba
Don duba abubuwan da ke cikin matattarar fayil ɗin ba tare da lalata shi ta amfani da gzip ba, za mu yi amfani da -c zaɓi kamar yadda aka nuna a cikin masu zuwa:
gunzip -c ubunlog1.txt.gz
Hakanan zamu iya amfani da amfani zcat don wannan dalili, kamar ƙasa:
zcat ubunlog.txt.gz
Za mu iya buto fitarwa ta amfani da umarnin "kaɗan" don duba shafin fitarwa ta shafi kamar yadda aka nuna a ƙasa:
gunzip -c ubunlog.txt.gz | less
Hakanan za'a iya amfani da ƙaramin umarni tare da zat:
zcat ubunlog.txt.gz | less
Hakanan zamu sami zaɓi don amfani da shirin zless. Wannan yana aiki iri ɗaya kamar bututun da suka gabata:
zless ubunlog.txt.gz
Podemos fita waje ta hanyar latsa maɓallin q.
-
Sanya fayil ɗin tare da gzip wanda ke bayyana matakin matsewa
Wani fa'ida don kiyaye gzip shine goyon bayan matsawa matakin. Na goyon bayan 3 matakai na matsawa kamar yadda ke ƙasa.
1 - Mai sauri (mafi munin)
9 - Sannu a hankali (mejor)
6 - Matsakaicin matakin
Don damfara fayil mai suna ubunlog.txt, maye gurbin shi da a versionunƙirar siga tare da mafi kyawun matakin matsewa, za mu yi amfani da:
gzip -9 ubunlog.txt
-
Haɗa fayilolin matsawa masu yawa
Wata dama da gzip ke bamu shine na hada fayiloli masu matsi da yawa cikin daya. Zamu iya yin hakan ta hanya mai zuwa:
gzip -c ubunlog1.txt > salida.txt.gz gzip -c ubunlog2.txt >> salida.txt.gz
Umurnai biyu na sama zasu damfara ubunlog1.txt da ubunlog2.txt kuma ajiye su a cikin fayil guda ɗaya mai suna fitarwa.txt.gz.
Zamu iya duba abubuwan da ke cikin fayilolin (ubunlog1 .txt kuma ubunlog1.txt) ba tare da cire su ba ta amfani da ɗayan waɗannan umarnin:
gunzip -c salida.txt.gz gunzip -c salida.txt zcat salida.txt.gz zcat salida.txt
Don ƙarin bayani game da gzip, duba mutum shafuka:
man gzip
Shirin bzip2
El bzip2 yayi kamanceceniya da shirin gzip. Babban bambanci shine cewa yana amfani da algorithm na matsawa daban wanda ake kira Burrows-Wheeler toshe tsarin matattara matattara algorithm da kuma sanya Huffman. Fayilolin da aka matse tare da bzip2 zasu ƙare tare da fadada .bz2.
Kamar yadda na ce, amfani da bzip2 daidai yake da gzip. Dole ne kawai muyi hakan maye gurbin gzip a cikin misalan da ke sama da bzip2, gunzip tare da bunzip2, zcat tare da bzcat da sauransu.
-
Matsa fayiloli
Don damfara fayil ta amfani da bzip2, maye gurbin shi tare da sigar matsawa, za mu kashe:
bzip2 ubunlog.txt
-
Damfara fayilolin ba tare da share asalin fayil ba
Idan ba mu son maye gurbin asalin fayil ɗin, za mu yi amfani da -c zaɓi kuma zamu rubuta sakamakon zuwa sabon fayil.
bzip2 -c ubunlog.txt > salida.txt.bz2
-
Cire fayiloli
para cire fayil matsa za mu yi amfani da ɗayan hanyoyi biyu masu zuwa:
bzip2 -d ubunlog.txt.bz2 bunzip2 ubunlog.txt.bz2
-
Duba abubuwan cikin fayilolin matsewa ba tare da rage su ba
Don ganin ƙunshin fayil ɗin da aka matse ba tare da rage shi ba, kawai za mu yi amfani da ɗayan zaɓuɓɓukan:
bunzip2 -c ubunlog.txt.bz2 bzcat ubunlog.txt.bz2
Don ƙarin cikakkun bayanai, zamu iya tuntuɓar mutum shafuka:
man bzip2