Linuxdoc Sgml/Bzip2
<!doctype linuxdoc system>
<article>
<title>
Bzip2 mini-HOWTO
<author>David Fetter, <url url="mailto:david@fetter.org" name="david@fetter.org">
<date>v2.00, 22 August 1999
<trans>¿ªÀÚ : ÀÌÈ£¿¬ <<url url="mailto:guru2k@kldp.org" name="guru2k@kldp.org" >>
<abstract>
ÀÌ ¹®¼´Â »õ·Î¿î ¾ÐÃà ÇÁ·Î±×·¥ÀÎ bzip2¸¦ ¾î¶»°Ô »ç¿ëÇÏ´ÂÁö À̾߱âÇÑ´Ù.
sgmlÀÇ ·ÎÄÃÄ«ÇÇ´Â ÇöÀçÀÇ »çÀÌÆ® <Bzip2-HOWTO.sgml> ¿¡ ÀÖ°í, "±ÇÀ§°¡ ÀÖ´Â"
sgmlÀº <<url url="http://fetter.org/Bzip2-HOWTO/" name="fetter.org/Bzip2-HOWTO">> ¿¡ ÀÖ´Ù.
</abstract>
<toc>
<sect> ¼Ò°³<p>
Bzip2´Â ÀڷḦ ¾ÐÃàÇϱâ À§ÇÑ ÁÁÀº »õ·Î¿î ¾Ë°í¸®ÁòÀÌ´Ù. ÀϹÝÀûÀ¸·Î
gzipÀ¸·Î ÇÑ °Í º¸´Ù 60-70%ÀÇ Å©±â·Î ¸¸µç´Ù.
ÀÌ ¹®¼´Â ´ç½ÅÀ» bzip2¸¦ ÅëÇÏ¿© ÀÏ¹Ý ¾ÖÇø®ÄÉÀ̼ÇÀ» ÀÌ¿ëÇÏ°Ô ¸¸µé °ÍÀÌ´Ù.
ÀÌ ¹®¼ÀÇ ¹Ì·¡ÀÇ ¹öÀüÀº bzip2¸¦ ¸¸µç Julian Seward
<<url url="mailto:Julian_Seward@muraroa.demon.co.uk" name="Julian_Seward@muraroa.demon.co.uk">> °¡ Ä£ÀýÈ÷ ¾´ bzip2
C ¶óÀ̺귯¸®ÀÎ libbzip2°¡ ÀÖÀ» °ÍÀÌ´Ù. ¶óÀ̺귯¸®¿¡ °üÇÑ ³·Àº ·¹º§ÀÇ
bzip2 ¸Þ´º¾óÀÌ <<url url="http://www.bzip2.org/bzip2/docs/manual_toc.html" name="www.bzip2.org/bzip2/docs/manual_toc.html" >> ¿¡ ÀÖ´Ù.
ÀÌ ¹®¼ÀÇ ¹Ì·¡ÀÇ ¹öÀüµéÀº ¾Æ¸¶ ¶ÇÇÑ bzip2¸¦ ¸®´ª½º Ä¿³Î¿¡¼ ½á¾ßÇÏ´ÂÁö
(±×¸®°í ¾î¶»°Ô)¿¡ °üÇÑ ÇØ¼³¿¡ ´ëÇÑ ¿ä¾àÀ» Æ÷ÇÔÇÒ °ÍÀÌ´Ù.
</p>
<sect1>°³Á¤ÆÇ ¿ª»ç
<sect2> v2.00<p>
``Bzip2¸¦ less¿Í °°ÀÌ »ç¿ëÇϱâ'' ºÎºÐÀÌ º¯°æµÇ¾ú´Ù ±×·¡¼ .tar.bzip2
ÆÄÀÏÀ» ½ÇÁ¦·Î ÀÐÀ»¼ö ÀÖ´Ù. Á¤Á¤ÇÑ °Í¿¡ ´ëÇØ Nicola Fabiano
<<url url="mailto:mc864mclink.it" name="mc864mclink.it" >> ¿¡°Ô °¨»çÇÑ´Ù.
buzzit À¯Æ¿¸®Æ¼°¡ °»½ÅµÇ¾ú´Ù.
tar Á¤º¸°¡ °»½ÅµÇ¾ú´Ù.
</p>
<sect2> v1.92<p>
``Bzip2 ¹ÙÀ̳ʸ® ¾ò±â'' ºÎ¹®ÀÌ º¯°æµÇ¾ú°í, S.u.S.E.¿¡ Ãß°¡ÇÑ °ÍÀ» Æ÷ÇÔ
ÇÑ´Ù.
</p>
<sect2> v1.91<p>
¿ÀŸ°¡ ±³Á¤µÇ¾ú°í ``Bzip2¸¦ tar°ú °°ÀÌ ¾²´Â ºÎ¹®''ÀÇ ¼Ð Ç¥ÇöÇü½ÄÀÇ ÀÏ
ºÎ¸¦ ±ú²ýÇÏ°Ô Çß´Ù. ÀÌ °Íµé¿¡ ´ëÇØ Alessandro Rubini¿¡°Ô °¨»çÇÑ´Ù.
ÃÖÃÊÀÇ bzip2 µ¥ÀÌÅ͸¦ Áþ¹âÁö ¾Ê±â À§ÇØ buzzit ÅøÀ» °»½ÅÇß´Ù.
Zgrep°°Àº ÅøÀÎ bgrep°¡ Ãß°¡µÇ¾ú´Ù.
</p>
<sect2> v1.9<p>
Gcc 2.7.* ¹®Á¦¸¦ ±ú²ýÇÏ°Ô Çß´Ù. À̰ÍÀ» ÁöÀûÇÑ Ulrik Dickow¿¡°Ô °¨»çÇÑ´Ù.
Leonard Jean-MarcÀÇ ÈǸ¢ÇÑ tar°ú °°ÀÌ »ç¿ëÇÏ´Â ¹æ¹ýÀÌ Ãß°¡µÇ¾ú´Ù.
Linux AkerlundÀÇ ½º¿þµ§ ¹ø¿ªÀÌ Ãß°¡µÇ¾ú´Ù.
Arnaud LaunayÀÇ Á¦¾ÈÀ¸·Î wu-ftpd ºÎ¹®À» °íÃÆ´Ù.
¹ø¿ªµéÀÌ ±×µé ÀÚ½ÅÀÇ ºÎ¹®À¸·Î ¿Å°ÜÁ³´Ù.
</p>
<sect2> v1.8<p>
Buzzit°ú ±×°ÍµéÀÌ ¼ÓÇѰ÷ÀÇ sgmlÀÇ tar.diff¸¦ ³Ö¾ú´Ù. ±¸µÎÁ¡°ú Çü½ÄÀ»
¼öÁ¤Çß´Ù. Arnaud Launay¿¡°Ô ³ªÀÇ º¹»ç¸¦ Á¤Á¤ÇÑ ±×ÀÇ µµ¿ò¿¡ ´ëÇØ °¨»ç
ÇÑ´Ù. :-)
´ëÁßÀÇ °ü½É ºÎÁ·À¸·Î »õ·Î¿î Àû´çÇÑ xv ÇÁ·ÎÁ§Æ®¸¦ Çß´Ù.
ÀÌ ¹®¼ÀÇ ¹Ì·¡ÀÇ ¹öÀüÀ» À§ÇÑ ¹®Á¦¸¦ Ãß°¡Çß´Ù.
</p>
<sect2> v1.7<p>
Buzzit À¯Æ¿¸®Æ¼°¡ Ãß°¡µÇ¾ú´Ù. Gnu tar¿¡ ´ëÇÑ ÆÐÄ¡¸¦ °íÃÆ´Ù.
</p>
<sect2> v1.6<p>
TenThumbsÀÇ Netscape enabler°¡ Ãß°¡µÇ¾ú´Ù.
¶ÇÇÑ ±×ÀÇ Á¦¾ÈÀ¸·Î lesspipe.sh¸¦ º¯°æÇß´Ù. Áö±Ýº¸´Ù ÈǸ¢ÇÏ°Ô ÀÛµ¿ÇÒ
°ÍÀÌ´Ù.</p>
<sect2> v1.5<p>
Arnaud LaunayÀÇ ÇÁ¶û½º¾î ¹ø¿ª, ±×¸®°í ±×ÀÇ wu-ftpd ÆÄÀÏÀÌ Ãß°¡µÇ¾ú´Ù.
</p>
<sect2> v1.4<p>
Tetsu IsajiÀÇ ÀϺ» ¹ø¿ªÀÌ Ãß°¡µÇ¾ú´Ù.
</p>
<sect2> v1.3<p>
Ulrik DickowÀÇ 19.30¿Í ´õ ³ôÀº ¼öÁØÀÇ .emacs°¡ Ãß°¡µÇ¾ú´Ù.
(¶ÇÇÑ ±×ÀÇ Á¦¾ÈÀ¸·Î emacsÀÇ jka-compr.elÆÐÄ¡°¡ Á¤Á¤µÇ¾ú´Ù.
ÀÌ·±! Bzip2ÀÇ Ç÷¡±×°¡ ¾ÆÁ÷(?) ¾ø±º.)
</p>
<sect2> v1.2<p>
EmacsÀÇ ÆÐÄ¡°¡ º¯°æµÇ¾î¼ ÀÚµ¿ÀûÀ¸·Î .bz2 ÆÄÀϵéÀ» ÀνÄÇÑ´Ù.
</p>
<sect2> v1.1<p>
EmacsÀÇ ÆÐÄ¡°¡ Ãß°¡µÇ¾ú´Ù.
</p>
<sect2> v1.0<p>
¶ó¿îµå 1.</p>
<sect> Bzip2 ¾ò±â<p>
Bzip2ÀÇ È¨ÆäÀÌÁö´Â ¿µ±¹ Ȩ »çÀÌÆ®ÀÎ <<url url="http://www.bzip2.org/" name="www.bzip2.org">>¿¡ ÀÖ°í.
¹Ì±¹ ¹Ì·¯»çÀÌÆ®´Â <<url url="http://www.digistar.com/bzip2/index.html" name="www.digistar.com/bzip2/index.html">> ¿¡ ÀÖ´Ù.
</p>
<sect1> ´ç½ÅÀÇ ¾ð¾îÀÇ bzip2-HOWTO<p>
ÇÁ¶û½ºÀεéÀº ¾Æ¸¶ Arnaud LaunayÀÇ ÇÁ¶û½º¾î ¹®¼¸¦ Âü°íÇϱ⸦ ¹Ù¶ö °ÍÀÌ´Ù.
À¥ ¹öÀüÀº <<url url="http://www.freenix.fr/linux/HOWTO/mini/Bzip2.html" name="www.freenix.fr/linux/HOWTO/mini/Bzip2.html" >> ¿¡ ÀÖ°í,
ftp´Â <url url="ftp://ftp.lip6.fr/pub/linux/french/docs/HOWTO/mini/Bzip2.gz" name="ftp.lip6.fr/pub/linux/french/docs/HOWTO/mini/Bzip2.gz" > ¿©±â ÀÖ´Ù.
Arnaud¿Í ÀüÀÚ¸ÞÀÏ·Î ¿¬¶ôÇÒ ¼ö ÀÖ´Ù. ¸ÞÀÏ ÁÖ¼Ò´Â <<url url="mailto:zoro@mygale.org" name="zoro@mygale.org" >> ÀÌ´Ù.
ÀϺ»ÀεéÀº ¾Æ¸¶ Tetsu IsajiÀÇ ÀϺ»¾î ¹®¼¸¦ ÂüÁ¶Çϱ⸦ ¹Ù¶ö °ÍÀÌ´Ù.
¹®¼´Â <<url url="http://jf.gee.kyoto-u.ac.jp/JF/JF.html" name="jf.gee.kyoto-u.ac.jp/JF/JF.html" >> ¿¡ ÀÖ´Ù. IsajiÀÇ
ȨÆäÀÌÁö <<url url="http://www2s.biglobe.ne.jp/~kaien/" name="www2s.biglobe.ne.jp/~kaien/" >>¿¡¼ ¿¬¶ôÇÒ¼ö ÀÖ°í, ȤÀº
ÀüÀÚ¸ÞÀÏ·Î ÇÒ ¼ö ÀÖ´Ù. ¸ÞÀÏ ÁÖ¼Ò´Â <<url url="mailto:isaji@mxu.meshnet.or.jp" name="isaji@mxu.meshnet.or.jp">> ÀÌ´Ù.
½º¿þµ§ÀεéÀº ¾Æ¸¶ Linus AkerlundÀÇ ½º¿þµ§¾î ¹®¼¸¦ ÂüÁ¶Çϱ⸦ ¹Ù¶ö °ÍÀÌ
´Ù. ¹®¼´Â <<url url="http://user.tninet.se/~uxm165t/linux_doc.html" name="user.tninet.se/~uxm165t/linux_doc.html" >> ¿¡ ÀÖ´Ù.
Linus¿Í ÀüÀÚ¸ÞÀÏ·Î ¿¬¶ôÇÒ¼ö ÀÖ´Ù. ¸ÞÀÏ ÁÖ¼Ò´Â <<url url="mailto:uxm165t@tninet.se" name="uxm165t@tninet.se">> ÀÌ´Ù.
</p>
<sect1> ÄÄÆÄÀÏµÈ bzip2 ¹ÙÀ̳ʸ® ¾ò±â<p>
Ȩ »çÀÌÆ®¸¦ ºÁ¶ó.</p>
<sect1> Bzip2 ¼Ò½º ¾ò±â<p>
°ø½ÄÀûÀÎ »çÀÌÆ®¿¡ ÀÖ´Ù (``Bzip2 ¾ò±â'' ¸¦ ºÁ¶ó.</p>
<sect1> ´ç½ÅÀÇ ÄÄÇ»ÅÍ·Î bzip2 ÄÄÆÄÀÏÇϱâ<p>
¸¸¾à ´ç½ÅÀÌ gcc 2.7.*À» °¡Áö°í ÀÖÀ¸¸é, ´ÙÀ½ ¶óÀÎÀ» ¹Ù²ã¶ó
CFLAGS = -O3 -fomit-frame-pointer -funroll-loops
À¸·Î
CFLAGS = -O2 -fomit-frame-pointer
-O3 °ú -O2¸¦ ¹Ù²Ù°í -funroll-loops¸¦ ³Ö´Â´Ù. Ä¿³Î ÄÄÆÄÀÏÇÒ¶§ ´ç½ÅÀº ¾Æ
¸¶ ¾î¶°ÇÑ -m* Ç÷¡±×¸¦(¿¹¸¦µé¾î, -m486) Ãß°¡ÇÏ±æ ¿øÇÒ °ÍÀÌ´Ù.
-funroll-loops¸¦ ÇÇÇÏ´Â °ÍÀº Á¦ÀÏ Áß¿äÇÑ ºÎºÐÀ̰í, gcc 2.7ÀÇ À߸øµÈ ÄÚ
µå¸¦ »ý¼ºÇÏ´Â ¸¹Àº ¿øÀÎÀÌ µÇ°í, gcc 2.7ÀÇ Äڵ尡 ´õ ´À¸®°í ´õ Ä¿Áö±â
¶§¹®ÀÌ´Ù. ´Ù¸¥ ÄÄÆÄÀÏ·¯µé (lcc, egcs, gcc 2.8.x)À» À§ÇØ µðÆúÆ® CFLAGS
°¡ ÁÁ´Ù.
±× ÈÄ, README´ë·Î ¹Ù·Î ±×°ÍÀ» ¸¸µé°í ¼³Ä¡Çضó.
</p>
<sect> Bzip2¸¦ ´Üµ¶À¸·Î ¾²±â <p>
ÁÁÀº ¸Þ´º¾ó ÆäÀÌÁö¸¦ ÀоîºÁ¶ó :)</p>
<sect> Bzip2¸¦ tar°ú °°ÀÌ ¾²±â<p>
¹Ù²Ù¾î ¸»Çϸé bzip2¸¦ tar°ú °°ÀÌ ¾²´Â ¼¼°¡Áö ¹æ¹ýÀÌ ¹Ø¿¡ ¸®½ºÆ® µÈ´Ù.
</p>
<sect1> °¡Àå ½¬¿î ¼³Ä¡:<p>
ÀÌ ¹æ¹ýÀº ÀüÇô ¼³Ä¡°¡ ÇÊ¿äÇÏÁö ¾Ê´Ù. ÇöÀç µð·ºÅ丮ÀÇ foo.tar.bz2ó·³
tar°ú bzip2·Î ¾ÐÃàµÈ °ÍÀ» Ç®·Á¸é
/path/to/bzip2 -cd foo.tar.bz2 | tar xf -
¶Ç´Â
tar --use-compress-prog=bzip2 xf foo.tar.bz2
ÀÌ ÀÛ¾÷Àº Á¾Á¾ PITA °¡ µÉ ¼öµµ ÀÖ´Ù.
</p>
<sect1> root Ư±Ç ¾øÀÌ ½±°Ô ¼³Ä¡ÇÏ°í »ç¿ëÇϱâ:<p>
ÆÁ¿¡ ´ëÇØ Leonard Jean-Marc <<url url="mailto:leonard@sct1.is.belgacom.be" name="leonard@sct1.is.belgacom.be" >>¿¡°Ô
°¨»çÇÑ´Ù. csh¿Í bash ±¸º°ÀÌ »ý±â´Â °Í¿¡ ´ëÇØ Alessandro Rubini
<<url url="mailto:rubini@morgana.systemy.it" name="rubini@morgana.systemy.it" >> ¿¡°Ô ¿ª½Ã °¨»çÇÑ´Ù.
´ç½ÅÀÇ .bashrc, À̰Ͱú °°Àº ¶óÀÎÀ» ³Ö¾î¶ó:
alias btar='tar --use-compress-program /usr/local/bin/bzip2 '
´ç½ÅÀÇ .tcshrc, ¶Ç´Â .cshrc, À̰Ͱú À¯»çÇÏ°Ô º¸ÀÌ´Â ¶óÀÎ:
alias btar 'tar --use-compress-program /usr/local/bin/bzip2'
</p>
<sect1> ·çÆ®ÀÇ Á¢±ÙÀÌ ÇÊ¿äÇÏÁö¸¸ ½±°Ô »ç¿ëÇϱâ.<p>
´ç½ÅÀÇ tarÀ» GNUÀÇ °¡Àå »õ·Î¿î ¹öÀüÀ¸·Î °»½ÅÇØ¶ó, ÇöÀç´Â 1.13.10ÀÌ´Ù.
±×°ÍÀº GNUÀÇ ftp »çÀÌÆ® <url url="ftp://alpha.gnu.org/gnu/tar/" name=" alpha.gnu.org/gnu/tar/" >¿¡¼ ãÀ» ¼ö ÀÖ°í
ȤÀº ¾î¶² ¹Ì·¯.
</p>
<sect> Bzip2¸¦ less¿Í °°ÀÌ ¾²±â<p>
bzip2À¸·Î ¾ÐÃàµÈ ÆÄÀÏÀ» bunzip2 ¾øÀÌ less¸¦ ÀÌ¿ëÇÏ·Á¸é lesspipr.sh
(man less) ÆÄÀÏÀ» ´ÙÀ½°ú °°ÀÌ ¸¸µé¾î¶ó:
<code>
#!/bin/sh
# This is a preprocessor for 'less'. It is used when this environment
# variable is set: LESSOPEN="|lesspipe.sh %s"
case "$1" in
*.tar) tar tvvf $1 2>/dev/null ;; # View contents of various tar'd files
*.tgz) tar tzvvf $1 2>/dev/null ;;
# This one work for the unmodified version of tar:
*.tar.bz2) bzip2 -cd $1 $1 2>/dev/null | tar tvvf - ;;
#This one works with the patched version of tar:
# *.tar.bz2) tyvvf $1 2>/dev/null ;;
*.tar.gz) tar tzvvf $1 2>/dev/null ;;
*.tar.Z) tar tzvvf $1 2>/dev/null ;;
*.tar.z) tar tzvvf $1 2>/dev/null ;;
*.bz2) bzip2 -dc $1 2>/dev/null ;; # View compressed files correctly
*.Z) gzip -dc $1 2>/dev/null ;;
*.z) gzip -dc $1 2>/dev/null ;;
*.gz) gzip -dc $1 2>/dev/null ;;
*.zip) unzip -l $1 2>/dev/null ;;
*.1|*.2|*.3|*.4|*.5|*.6|*.7|*.8|*.9|*.n|*.man) FILE=`file -L $1` ; # groff src
FILE=`echo $FILE | cut -d ' ' -f 2`
if [ "$FILE" = "troff" ]; then
groff -s -p -t -e -Tascii -mandoc $1
fi ;;
*) cat $1 2>/dev/null ;;
# *) FILE=`file -L $1` ; # Check to see if binary, if so -- view with 'strings'
# FILE1=`echo $FILE | cut -d ' ' -f 2`
# FILE2=`echo $FILE | cut -d ' ' -f 3`
# if [ "$FILE1" = "Linux/i386" -o "$FILE2" = "Linux/i386" \
# -o "$FILE1" = "ELF" -o "$FILE2" = "ELF" ]; then
# strings $1
# fi ;;
esac
</code>
</p>
<sect> Bzip2¸¦ emacs¿Í °°ÀÌ ¾²±â
<sect1> ¸ðµÎ¸¦ À§ÇØ emacs ¹Ù²Ù±â:
<p>
³ª´Â ÀÚµ¿¾ÐÃà¸ðµå¸¦ Ãß°¡ÇÑ jka-compr.el ÆÐÄ¡¿¡ µû¶ó ½è´Ù.
ºÎÀμ: ³ª´Â emacs-20.0¿¡¼¸¸ Å×½ºÆ®¸¦ ÇØºÃ´Ù, ±×·¯³ª ´Ù¸¥ ¹öÀü¿¡ ºñ½Á
ÇÏ°Ô Á¢±ÙÇÏÁö ¸øÇÑ´Ù°í ¹ÏÀ» ÀÌÀ¯°¡ ¾ø´Ù.
ÀÌ °ÍÀ» ½á¶ó,
<enum>
<item> emacs-20.2/lisp ¼Ò½º µð·ºÅ丮¿¡ °¡¶ó (´ç½ÅÀÌ tarÀ» Ǭ °÷)
<item> jka-compr.el.diff ºÎ¸£´Â ÆÄÀÏÀÇ ¾Æ·¡¿¡ ÆÐÄ¡¸¦ ³õ¾Æ¶ó (±× °ÍÀº Àú ÆÄÀÏ
¿¡ ´Üµ¶À¸·Î ÀÖ¾î¾ßÇÑ´Ù ;).
<item> ÇØ¶ó
patch < jka-compr.el.diff
<item> Emacs¸¦ ½ÃÀÛÇØ¶ó, ±×¸®°í ÇØ¶ó
M-x byte-compile-file jka-compr.el
<item> Emacs¸¦ Á¾·áÇØ¶ó.
<item> ´ç½ÅÀÇ ÃÖÃÊÀÇ jka-compr.elc¸¦ ¹ö±×ÀÇ ÄÉÀ̽º¾ÈÀÇ ¾ÈÀüÇÑ °÷À¸·Î ¿Å°Ü¶ó.
<item> »õ·Î¿î jka-compr.elc¿Í ±× °ÍÀ» ¹Ù²ã¶ó.
<item> Áñ°Ü¶ó!
</enum>
<code>
--- jka-compr.el Sat Jul 26 17:02:39 1997
+++ jka-compr.el.new Thu Feb 5 17:44:35 1998
@@ -44,7 +44,7 @@
;; The variable, jka-compr-compression-info-list can be used to
;; customize jka-compr to work with other compression programs.
;; The default value of this variable allows jka-compr to work with
-;; Unix compress and gzip.
+;; Unix compress and gzip. David Fetter added bzip2 support :)
;;
;; If you are concerned about the stderr output of gzip and other
;; compression/decompression programs showing up in your buffers, you
@@ -121,7 +121,9 @@
;;; I have this defined so that .Z files are assumed to be in unix
-;;; compress format; and .gz files, in gzip format.
+;;; compress format; and .gz files, in gzip format, and .bz2 files,
+;;; in the snappy new bzip2 format from <url url="http://www.muraroa.demon.co.uk" name="www.muraroa.demon.co.uk" >.
+;;; Keep up the good work, people!
(defcustom jka-compr-compression-info-list
;;[regexp
;; compr-message compr-prog compr-args
@@ -131,6 +133,10 @@
"compressing" "compress" ("-c")
"uncompressing" "uncompress" ("-c")
nil t]
+ ["\\.bz2\\'"
+ "bzip2ing" "bzip2" ("")
+ "bunzip2ing" "bzip2" ("-d")
+ nil t]
["\\.tgz\\'"
"zipping" "gzip" ("-c" "-q")
"unzipping" "gzip" ("-c" "-q" "-d")
</code>
</p>
<sect1> ÇÑ »ç¶÷À» À§ÇØ emacs ¹Ù²Ù±â:<p>
Kampsax Technology¿¡ ÀÖ´Â ½Ã½ºÅÛ ÇÁ·Î±×·¡¸ÓÀÎ Ulrik Dickow, <url url="mailto:ukd@kampsax.dk" name="ukd@kampsax.dk" >
<mailto:ukdATkampsax.dk> ¿¡°Ô À̰Ϳ¡ °üÇØ °¨»çÇÑ´Ù:
´ç½ÅÀÌ ½Ã½ºÅÛ°ü¸®ÀÚ°¡ ¾Æ´Ò¶§ ±×°ÍÀ» ¸¸µé¸é bzip2¸¦ ÀÚµ¿ÀûÀ¸·Î ¾µ ¼ö ÀÖ´Ù.
´ç½ÅÀÇ .emacs ÆÄÀÏ´ÙÀ½¿¡ Áö±Ý Ãß°¡Çضó.
<code>
;; Automatic (un)compression on loading/saving files (gzip(1) and similar)
;; We start it in the off state, so that bzip2(1) support can be added.
;; Code thrown together by Ulrik Dickow for ~/.emacs with Emacs 19.34.
;; Should work with many older and newer Emacsen too. No warranty though.
;;
(if (fboundp 'auto-compression-mode) ; Emacs 19.30+
(auto-compression-mode 0)
(require 'jka-compr)
(toggle-auto-compression 0))
;; Now add bzip2 support and turn auto compression back on.
(add-to-list 'jka-compr-compression-info-list
["\\.bz2\\(~\\|\\.~[0-9]+~\\)?\\'"
"zipping" "bzip2" ()
"unzipping" "bzip2" ("-d")
nil t])
(toggle-auto-compression 1 t)
</code>
</p>
<sect> Bzip2¸¦ wu-ftpd¿Í °°ÀÌ ¾²±â<p>
Arnaud Launay¿¡°Ô ÀÌ bandwidth ¼¼À̹ö¿¡ ´ëÇØ °¨»çÇÑ´Ù. À̰ÍÀº bzip2
¾ÐÃà°ú ¾ÐÃàÇØÁ¦¸¦ /etc/ftpconversions ¿¡ ÇÑ´Ù. °æ·Î¸¦ Á¤È®È÷ ÇØ¾ß ÇÒ
°ÍÀ» ¸í½ÉÇ϶ó.
<code>
:.Z: : :/bin/compress -d -c %s:T_REG|T_ASCII:O_UNCOMPRESS:UNCOMPRESS
: : :.Z:/bin/compress -c %s:T_REG:O_COMPRESS:COMPRESS
:.gz: : :/bin/gzip -cd %s:T_REG|T_ASCII:O_UNCOMPRESS:GUNZIP
: : :.gz:/bin/gzip -9 -c %s:T_REG:O_COMPRESS:GZIP
:.bz2: : :/bin/bzip2 -cd %s:T_REG|T_ASCII:O_UNCOMPRESS:BUNZIP2
: : :.bz2:/bin/bzip2 -9 -c %s:T_REG:O_COMPRESS:BZIP2
: : :.tar:/bin/tar -c -f - %s:T_REG|T_DIR:O_TAR:TAR
: : :.tar.Z:/bin/tar -c -Z -f - %s:T_REG|T_DIR:O_COMPRESS|O_TAR:TAR+COMPRESS
: : :.tar.gz:/bin/tar -c -z -f - %s:T_REG|T_DIR:O_COMPRESS|O_TAR:TAR+GZIP
: : :.tar.bz2:/bin/tar -c -y -f - %s:T_REG|T_DIR:O_COMPRESS|O_TAR:TAR+BZIP2
</code>
</p>
<sect> Bzip2¸¦ grep¿Í °°ÀÌ ¾²±â<p>
³»°¡ bgrepÀ» ½ÇÇàÇÒ ¶§¿¡´Â linux ¿Í °°ÀÌ ¿À´Â zgrep¿¡ »ç¼ÒÇÑ ¼öÁ¤ÀÌ
°¡ÇØÁø´Ù. ´ç½ÅÀº bunzip2 ¸í·ÉÀÇ »ç¿ë ¾øÀ̵µ ÀÏ´ÜÀº grepÀ» »ç¿ëÇÒ ¼ö ÀÖÀ»
°ÍÀÌ´Ù.
<code>
#!/bin/sh
# bgrep -- a wrapper around a grep program that decompresses files as needed
PATH="/usr/bin:$PATH"; export PATH
prog=`echo $0 | sed 's|.*/||'`
case "$prog" in
*egrep) grep=${EGREP-egrep} ;;
*fgrep) grep=${FGREP-fgrep} ;;
*) grep=${GREP-grep} ;;
esac
pat=""
while test $# -ne 0; do
case "$1" in
-e | -f) opt="$opt $1"; shift; pat="$1"
if test "$grep" = grep; then # grep is buggy with -e on SVR4
grep=egrep
fi;;
-*) opt="$opt $1";;
*) if test -z "$pat"; then
pat="$1"
else
break;
fi;;
esac
shift
done
if test -z "$pat"; then
echo "grep through bzip2 files"
echo "usage: $prog [grep_options] pattern [files]"
exit 1
fi
list=0
silent=0
op=`echo "$opt" | sed -e 's/ //g' -e 's/-//g'`
case "$op" in
*l*) list=1
esac
case "$op" in
*h*) silent=1
esac
if test $# -eq 0; then
bzip2 -cd | $grep $opt "$pat"
exit $?
fi
res=0
for i do
if test $list -eq 1; then
bzip2 -cdfq "$i" | $grep $opt "$pat" > /dev/null && echo $i
r=$?
elif test $# -eq 1 -o $silent -eq 1; then
bzip2 -cd "$i" | $grep $opt "$pat"
r=$?
else
bzip2 -cd "$i" | $grep $opt "$pat" | sed "s|^|${i}:|"
r=$?
fi
test "$r" -ne 0 && res="$r"
done
exit $res
</code>
</p>
<sect> Bzip2¸¦ XÀÇ ³Ý½ºÄÉÀÌÇÁ°ú °°ÀÌ ¾²±â.<p>
<url url="mailto:tenthumbs@cybernex.net " name="tenthumbs@cybernex.net >says:
³ª´Â gzipÀÌ »ç¿ëµÇ´ø ¸®´ª½º¿ë ³Ý½ºÄÉÀÌÇÁ¿¡¼ÀÇ ¹®¼ÀÇ ÀÎÄÚµùÀ» bzip2¸¦
ÀÌ¿ëÇÏ¿© ÇÒ ¼ö ÀÖ´Â ¹æ¹ýµµ ã¾Æ³»¾ú´Ù. ´ÙÀ½À» $HOME/.Xdefaults À̳ª
$HOME/.Xresources ¿¡ Ãß°¡Çضó.
³ª´Â -s ¿É¼ÇÀ» »ç¿ëÇߴµ¥ ±×°ÍÀº ·¥ÀÇ »ç¿ë»ó ¾î¶² °æ¿ì¿¡´Â ¾ÐÃà ÇØÁ¦
¼Óµµ°¡ ´õ »¡¶ú±â ¶§¹®ÀÌ´Ù. ´ç½ÅÀº ¿øÇÑ´Ù¸é ÀÌ ¿É¼ÇÀº »©µµ ÁÁÀ» °ÍÀÌ´Ù.
<code>
Netscape*encodingFilters: \
x-compress : : .Z : uncompress -c \n\
compress : : .Z : uncompress -c \n\
x-gzip : : .z,.gz : gzip -cdq \n\
gzip : : .z,.gz : gzip -cdq \n\
x-bzip2 : : .bz2 : bzip2 -ds \n
</code>
</p>
<sect> Bzip2·Î ´Ù¸¥ ¾ÐÃà Çü½ÄÀ¸·Î ¾ÐÃàµÈ°É ´Ù½Ã ¾ÐÃàÇϱâ<p>
ÆÞ ÇÁ·Î±×·¥À» ÀÌ¿ëÇÏ¿© ÇÑ ¹ø ¾ÐÃàµÈ (.tar.gz, .tgz, .tar.Z, .Z,
ȤÀº ±âŸ) ÆÄÀÏÀ» ´õ ³ªÀº ¾ÐÃàÆÄÀÏ·Î ´Ù½Ã ¾ÐÃàÇÒ ¼ö ÀÖ´Ù. ÀÌ ÆÞ
¼Ò½º´Â ¹«¾ùÀ» ÇÒ °ÍÀΰ¡¿Í ¹«¾ùÀ» ¾î¶»°Ô ÇÒ °ÍÀΰ¡¿¡ ´ëÇÑ ¸ðµç
Á¾·ùÀÇ °£°áÇÑ ¹®¼¸¦ Æ÷ÇÔÇϰí ÀÖ´Ù. À̰ÍÀÇ ÃÖÁ¾ ¹öÀüÀº ¸í·ÉÇà¿¡
ÆÄÀÏ À̸§À» ÀÔ·ÂÇÏ°Ô ÇÑ´Ù. ¸í·ÉÇà¿¡¼ µû·ÎÀÌ ÁöÁ¤µÈ °ÍÀÌ ¾øÀ¸¸é
±×°ÍÀº ÀÛ¾÷ µð·ºÅ丮 ¾ÈÀÇ ¸ðµç °ÍÀ» ´Ù½Ã¾ÐÃàÇÑ´Ù.
<code>
#!/usr/bin/perl -w
#######################################################
# #
# This program takes compressed and gzipped programs #
# in the current directory and turns them into bzip2 #
# format. It handles the .tgz extension in a #
# reasonable way, producing a .tar.bz2 file. #
# #
#######################################################
$counter = 0;
$saved_bytes = 0;
$totals_file = '/tmp/machine_bzip2_total';
$machine_bzip2_total = 0;
@raw = (defined @ARGV)?@ARGV:<*>;
foreach(@raw) {
next if /^bzip/;
next unless /\.(tgz|gz|Z)$/;
push @files, $_;
}
$total = scalar(@files);
foreach (@files) {
if (/tgz$/) {
($new=$_) =~ s/tgz$/tar.bz2/;
} else {
($new=$_) =~ s/\.g?z$/.bz2/i;
}
$orig_size = (stat $_)[7];
++$counter;
print "Repacking $_ ($counter/$total)...\n";
if ((system "gzip -cd $_ |bzip2 >$new") == 0) {
$new_size = (stat $new)[7];
$factor = int(100*$new_size/$orig_size+.5);
$saved_bytes += $orig_size-$new_size;
print "$new is about $factor% of the size of $_. :",($factor<100)?')':'(',"\n";
unlink $_;
} else {
print "Arrgghh! Something happened to $_: $!\n";
}
}
print "You've "
, ($saved_bytes>=0)?"saved ":"lost "
, abs($saved_bytes)
, " bytes of storage space :"
, ($saved_bytes>=0)?")":"("
, "\n"
;
unless (-e '/tmp/machine_bzip2_total') {
system ('echo "0" >/tmp/machine_bzip2_total');
system ('chmod', '0666', '/tmp/machine_bzip2_total');
}
chomp($machine_bzip2_total = `cat $totals_file`);
open TOTAL, ">$totals_file"
or die "Can't open system-wide total: $!";
$machine_bzip2_total += $saved_bytes;
print TOTAL $machine_bzip2_total;
close TOTAL;
print "That's a machine-wide total of ",`cat $totals_file`," bytes saved.\n";
</code>
</p>
</article>
|
You will overcome the attacks of jealous associates. |











