Bzip2 Howto <author>§@ªÌ: <newline> David Fetter, <url url="mailto:dfetter@best.com" name="dfetter@best.com"> <newline> ĶªÌ:<newline> Á±X¤¤ HSIEH KUN-CHUNG, ¥xÆW ¤¤µØ¥Á°ê Taiwan, Republic of China (NOT People's Republic of China) (¹q¤l¶l¥ó <tt><htmlurl url="mailto:linuxer.bbs@cis.nctu.edu.tw" name="linuxer.bbs@cis.nctu.edu.tw"></tt> ©Î<tt><htmlurl url="mailto:linux4tw@geocities.com" name="linux4tw@geocities.com"></tt> ºô­¶ "Linux for Taiwan ¥xÆW¤Hªº Linux" <tt><htmlurl url="http://members.xoom.com/linux4tw/" name="http://members.xoom.com/linux4tw/"></tt> <newline> <date>ª©¥» v1.92¡A1998¦~ 8¤ë18¤é <abstract> ³o¥÷¤å¥ó¦b±Ð§A¦p¦ó¨Ï¥Î·sªº bzip2 À£ÁYµ{¦¡¡C¥Ø«eªº sgml ª©¥»³Q©ñ¦b EURO <url url="Bzip2-HOWTO.sgml" name="³oùØ">¡AÁÙ¦³ "§@ªÌ¥Îªº" sgml ÀÉ©ñ¦b <url url="http://www.best.com/~dfetter/Bzip2-HOWTO/Bzip2-HOWTO.sgml" name="³o¨à">¡C </abstract> <!-- Table of contents --> <toc> <!-- Begin the document --> <sect>²¤¶ <p> Bzip2 ¬O­Ó«Ü´ÎªºÀ£ÁY¸ê®Æ¥Î¤§·s«¬ºtºâªk¡C¤j­P¤W¯à°÷¹F¨ì¥H¥¦ªº¹ï¤â gzip ©Ò²£¥XªºÀɮפ§ 60-70% ¥ª¥kªºÀ£ÁY²v¡C <p> ³o¥÷¤å¥ó±N±Ð§A´X­Ó bzip2 ªºÀ³¥Î³nÅé¡C <p> ¥»¤å¥óªº¥¼¨Óª©±N·|°Q½×§Y±N¥X²{ªº bzip2 µ{¦¡®w¡A¸Óµ{¦¡®w ­ìbzip2 ªº§@ªÌ <url url="mailto:Julian_Seward@muraroa.demon.co.uk" name="Julian Seward"> ´y­z¦p¤U: <verb> ²{¦b¥¿­P¤O©ó bzip2 ªº¤U¤@­Óª©¥»¡A¥¦¤]±N±Ä¥Î¬Û¦Pªº .bz2 Àɮ׮榡¡F ¥D­n¼W¥[ªº¥\¯à¬O¤@­Ó¹³ zlib ªºµ{¦¡®w¡CÅý§Ú­Ì¥i¥H±qµ{¦¡ùØÀY¨ÓŪ¨ú©M®Ñ¼g¸ê®Æ¨ì³oºØ®æ¦¡ªºÀÉ®×ùØ¡C </verb> <p> ¥»¤å¥óªº¥¼¨Óª©¥»¤]·|¥]§t¬O§_À³¸Ó (¥H¤Î¦p¦ó)Åý Linux kernel ¨Ï¥Î bzip2¤§Ä³ÃDªºµ²½×¡C <sect1> <bf>ªu­²¾ú¥v</bf> <sect2> v1.92 §ó·s <ref id="bzip2-binaries" name="¨ú±o bzip2 ¤G¶i¦ìµ{¦¡½X"> ³¹¸`¡A¥[¤J S.u.S.E.ªº¡C <sect2> v1.91 <p> ¦b <ref id="bzip2-with-tar" name="¨Ï¥Î bzip2 °t¦X tar ¨º³¹ùØ">­×¥¿¤@­Ó½d¨Ò¥H¤Î §Ë²M·¡¤@¨Ç shell ¥y¤l¡C·PÁ Alessandro Rubini¡C <p> §ó·s buzzit ¤u¨ã¤£·|¥h stomp ­ì¨Óªº bzip2 À£ÁYÀÉ¡C <p> ·s¼W bgrep, ¹³ zgrep-ªº¤u¨ã¡C <sect2> v1.9 <p> ¼á²M gcc 2.7.* ªº°ÝÃD¡C·PÁ Ulrik Dickow ªº¼ö¤ß«ü¥X¡C <p> ¥[¤J Leonard Jean-Marc «Ü´Îªº°t¦X tar <p> ¥[¤W Linus Ãkerlund ªº·ç¨å¤åª©¥»¡C <p> ¨Ì·Ó Arnaud Launay ªº«ØÄ³­×¥¿¤F wu-ftpd ³¹¸` <p> §âͤå©ñ¨ì¥¦­Ì¦Û¤vªº¦ì³¹¸`¤W¡C <sect2> v1.8 <p> §â buzzit ©M tar.diff ©ñ¨ì sgml ¤å¥óùØ¥¦­ÌÀ³¸Ó³Q©ñ¸mªº¦a¤è¡C ­×¥¿«÷¦r»P®æ¦¡¡C·PÁ Arnaud Launay ªº¨ó§U§Ú­×¥¿³o¥÷¤å¥ó¡C:-) <p> ±þ±¼ xv ­pµe¡A¦]¦¹¤j®a¤£·P¿³½ì¡C <p> ¥[¤W teasers ¬°¥»¤å¥óªº¥¼¨Óª©¥»¡C <sect2> v1.7 <p> ¥[¤J buzzit ¤½¥Îµ{¦¡¡C­×¥¿¹ï gnu tar ªº­×¸É¡C <sect2> v1.6 <p> ¥[¤J TenThumbs ªº Netscape ­P¯àªÌ¡C <p> ¥H¤Î¨Ì¾Ú¥¦ªº«ØÄ³§ó§ï lesspipe.sh ¡C¥¦²{¦b¥i¥H¤u§@ªº§ó¦n¤F¡C <sect2> v1.5 <p> ¥[¤J Arnaud Launay ªºªk¤åĶ¥»¡A¥H¤Î¥Lªº wu-ftpd ÀÉ¡C <sect2> v1.4 <p> ¥[¤J Tetsu Isaji ªº¤é¤åĶ¥»¡C <sect2> v1.3 <p> ¥[¤J Ulrik Dickow µ¹ 19.30 ©Î§ó°ªª©¥»¥Îªº .emacs ÀÉ¡ <p>(ÁÙ¦³­×¥¿µ¹ emacs¥Îªº jka-compr.el ­×¸ÉÀÉ¡CÁV¤F! Bzip2 ÁÙ¨S¦³(?) "append" ªººX¼Ð¿ï¶µ¡C) <sect2> v1.2 <p> ¥[¤J¹ï emacs ªº­×¸É¡AÅý¥¦¥i¥H¦Û°Ê¦a¿ìÃÑ¥X .bz2 ÀÉ¡C <sect2> v1.1 <p> ¥[¤J¹ï emacs <sect2> v1.0 <p> ²Ä¤@¦^¦X¡C <sect>¨ú±o bzip2<label id="get-bzip2"> <p> Bzip2 ªº¥Dºô­¶¦b <url url="http://www.muraroa.demon.co.uk/" name= "­^°êªº¥Dºô¯¸">¡C ¬ü°êªº¬M®g¯¸¦b <url url="http://www.digistar.com/bzip2/index.html" Name="³oùØ">¡C§A¤]¥i¥H¦b Red Hat ªºftp ¯¸ùØ <url url="ftp://ftp.redhat.com/pub/contrib" name="§ä¨ì">¡C <sect1>Bzip2-HOWTO ¦UºØ»y¨¥ª©¥» <p> »¡ªk»yªº¤H¥i¥H¬Ý¬Ý Arnaud Launay ªºªk¤å¤å¥ó¡C ºô­¶ª©¥»¦b <url url="http://www.freenix.fr/linux/HOWTO/mini/Bzip2.html" name="³oùØ">¡A§A¥i¥H¥Î ftp <url url="ftp://ftp.lip6.fr/pub/linux/french/docs/HOWTO/mini/Bzip2.gz" name="¨Ó¨ú±o"> §A¥i¥H¥Î<url url="mailto:zoro@mygale.org" name="¹q¤l¶l¥ó">¨Ó³sµ¸Arnaud <p> »¡¤é»yªº¤H¥i¥H¬Ý¬Ý Tetsu Isajiªº <url url="http://jf.gee.kyoto-u.ac.jp/JF/JF.html" name="¤é¤åĶ¥»">¡C §A¥i¥H¥Î¤WIsajiªº <url url="http://www2s.biglobe.ne.jp/~kaien/" name="ºô¯¸">¡A©Î¬O¥Î <url url="mailto:isaji@mxu.meshnet.or.jp" name="¹q¤l¶l¥ó">ªº¤è¦¡¡C <p> »¡·ç¨å»yªºªB¤Í¥i¥H°Ñ¾\ Linus Ãkerlund ªº·ç¨å¤åĶ¥» <url url="http://user.tninet.se/~uxm165t/linux_doc.html" name="«ö³o">¡C§A¥i¥H¥Î <url url="mailto:uxm165t@tninet.se" name="¹q¤l¶l¥ó"> »P Linus ³sµ¸¡C <sect1>¨ú±o bzip2 ¥¼½sĶªº¤G¶i¦ìÀÉ<label id="bzip2-binaries"> <p>¬d¤@¤U¥Dºô¯¸¡C <p>Debian ªºIntel ¤G¶i¦ìµ{¦¡½X¦b <url url="ftp://ftp.debian.org/debian/dists/stable/main/binary-i386/utils/bzip2_0.1pl2-5.deb" name="³oùØ">¡C <p>Red Hatªº alpha ¤G¶i¦ìµ{¦¡½X¦b <url url="ftp://ftp.redhat.com/pub/redhat/redhat-5.1/alpha/RedHat/RPMS/bzip2-0.1pl2-1.alpha.rpm" name="³oùØ">¡C <p>Red Hatªº Intel ¤G¶i¦ìµ{¦¡½X¦b <url url="ftp://ftp.redhat.com/pub/redhat/redhat-5.1/i386/RedHat/RPMS/bzip2-0.1pl2-1.i386.rpm" name="³oùØ">¡C <p>Red Hatªº SPARC ¤G¶i¦ìµ{¦¡½X¦b <url url="ftp://ftp.redhat.com/pub/redhat/redhat-5.1/sparc/RedHat/RPMS/bzip2-0.1pl2-1.sparc.rpm" name="³oùØ">¡C <p> Slackwareªº Intel ¤G¶i¦ìµ{¦¡½X¦b <url url="ftp://www.cdrom.com/pub/linux/slackware-3.5/slakware/a1/bzip2.tgz" name="³oùØ">¡C <p> S.u.S.E.ªº Intel ¤G¶i¦ìµ{¦¡½X¦b <url url="ftp://ftp.suse.com/pub/SuSE-Linux/5.2/suse/ap1/bzip.rpm" name="³oùØ">¡C §A¤]¥i¥H±q³\¦h¬ÛÃþ¦üªº¬M®g¯¸±o¨ú±oÀɮסC <sect1>¨ú±o bzip2 ­ì©lµ{¦¡ <p>§A¥i¥H±q©x¤èªººô¯¸ (¬Ý <ref id="get-bzip2" name="Getting Bzip2"> ¡A©Î¬O Red Hat ¤]¦³ <url url="ftp://ftp.redhat.com/pub/contrib/SRPMS/bzip2-0.1pl2-1.src.rpm" name="¥¦">)¡C <sect1>½sĶ bzip2 µ¹§Aªº¾÷¾¹¨Ï¥Î <p><bf>¦pªG§A¦³ gcc 2.7.*</bf>¡A±N¤U­±³o¦æ <tscreen><verb> CFLAGS = -O3 -fomit-frame-pointer -funroll-loops </verb></tscreen> <p>§ï¦¨ <tscreen><verb> CFLAGS = -O2 -fomit-frame-pointer </verb></tscreen> <p> ¤]´N¬O¡A§â -O2 §ï¦¨ -O3 ¨Ã§â -funroll-loops§R±¼¡C§A¤]¥i¥H¥[¤J¥ô¦ó§A¦b½sĶ kernel ®Éªº -m* ºX¼Ð (¨Ò¦p¹³ -m486)¡C <p> Á×§K¨Ï¥Î -funroll-loops ¬O³Ì­«­nªº¤F¡A¦]¬°¥¦·|³y¦¨³\¦hªº gcc 2.7²£¥Í¿ù»~ªºµ{¦¡½X¡A¥H¤Î¥þ³¡ªº gcc 2.7 ²£¥Í³t«×ºC¤S¸û­Dªºµ{¦¡½X¡C ¹ï¨ä¥Lªº½s;¹ (lcc, egcs, gcc 2.8.x) ¨Ï¥Î¤º©wªº CFLAGS ´N¨S°ÝÃD¡C <p> ¤§«á¡A¥u»Ý <tt/make/ ¥¦¡AµM«á¨Ì·Ó README ¨Ó¦w¸Ë¥¦¡C <sect>¨Ï¥Î bzip2 <p>½Ð°Ñ¾\«Ü´Îªº¤â¥U :) <sect>°t¦X tar¨Ó¨Ï¥Î bzip2<label id="bzip2-with-tar"> <p>¤U­±¦³¤TºØ°t¦X tar ¨Ï¥Î bzip2 ªº¤èªk¡A¤]´N¬O <sect1>®e©ö³]¥ß: <p>³o­Ó¤èªk¸ò¥»´N¤£¥²°µ³]©w¡C°õ¦æ¸Ñ¶}bzip2'd ªº tar¥]»q¡A ¦b²{¦æ¥Ø¿ý©³¤U¦³­Ó foo.tar.bz2¡A°õ¦æ <tscreen><verb> /path/to/bzip2 -cd foo.tar.bz2 | tar xf - </verb></tscreen> <p>¦¨¥\¤F¡A¦ý¥i¯à¦³±`»Ý¿é¤Jªº¤p¯ÊÂI¡C <sect1>®e©ö³]¥ß¡A®e©ö¨Ï¥Î¡A¤£»Ý­n root ªº¯SÅv: <p> ·PÁ <url url="mailto:leonard@sct1.is.belgacom.be" name="Leonard Jean-Marc"> °^Äm³o­Ó¤p§Þ¥©¡C¤]ÁÂÁ <url url="mailto:rubini@morgana.systemy.it" name="Alessandro Rubini"> ±q cshùؤÀÃþ ¥X bash ªº¡C <p>¦b§Aªº .bashrcùØ¡A§A¥i¥H¥[¤J¹³¤U­±³o¦æ: <tscreen><verb> alias btar='tar --use-compress-program /usr/local/bin/bzip2 ' </verb></tscreen> <p>¦b§Aªº .tcshrc ©Î .cshrcùØ¡A¥i¥Î¤U­±³o¦æ¬Û¦Pªº: <tscreen><verb> alias btar 'tar --use-compress-program /usr/local/bin/bzip2' </verb></tscreen> <sect1>¦P¼Ë¬O®e©ö¨Ï¥Î¡A¦ý»Ý­n root ¨Ó¦s¨ú¡C <p>¥Î¤U­±¨Ó¤èªk¨Ó­×¸É gnu tar 1.12¡G <tscreen><verb> cd tar-1.12/src; patch < /path/to/tar.diff </verb></tscreen> ½sĶ¡B¦w¸Ë¥¦¡A§A¤w·Ç³Æ´Nºü¤F¡C¥Î"which tar" ©M "which bzip2"¨Ó½T»{³o¨â­Ó tar ©M bzip2 ¦³¦b§Aªº $PATH ùØ¡C­n¨Ï¥Î·sªº tar¡A¥u»Ý <tscreen><verb> tar xyf foo.tar.bz2 </verb></tscreen> ¨ÓÀ£ÁYÀɮסC <p>­n»s§@·sªºÀ£ÁYÀÉ¡A¦P¼Ë¦a: <tscreen><verb> tar cyf foo.tar.bz2 ÀɦW1 ÀɦW2 ÀɦW3...¥Ø¿ý1 ¥Ø¿ý2... </verb></tscreen> <p> ¤U­±¬O­×¸Éªº¦a¤è: <verb> *** tar.c Thu Jun 11 00:09:23 1998 --- tar.c.new Thu Jun 11 00:14:24 1998 *************** *** 196,201 **** --- 196,203 ---- {"block-number", no_argument, NULL, 'R'}, {"block-size", required_argument, NULL, OBSOLETE_BLOCKING_FACTOR}, {"blocking-factor", required_argument, NULL, 'b'}, + {"bzip2", required_argument, NULL, 'y'}, + {"bunzip2", required_argument, NULL, 'y'}, {"catenate", no_argument, NULL, 'A'}, {"checkpoint", no_argument, &checkpoint_option, 1}, {"compare", no_argument, NULL, 'd'}, *************** *** 372,377 **** --- 374,380 ---- PATTERN at list/extract time, a globbing PATTERN\n\ -o, --old-archive, --portability write a V7 format archive\n\ --posix write a POSIX conformant archive\n\ + -y, --bzip2, --bunzip2 filter the archive through bzip2\n\ -z, --gzip, --ungzip filter the archive through gzip\n\ -Z, --compress, --uncompress filter the archive through compress\n\ --use-compress-program=PROG filter through PROG (must accept -d)\n"), *************** *** 448,454 **** Y per-block gzip compression */ #define OPTION_STRING \ ! "-01234567ABC:F:GK:L:MN:OPRST:UV:WX:Zb:cdf:g:hiklmoprstuvwxz" static void set_subcommand_option (enum subcommand subcommand) --- 451,457 ---- Y per-block gzip compression */ #define OPTION_STRING \ ! "-01234567ABC:F:GK:L:MN:OPRST:UV:WX:Zb:cdf:g:hiklmoprstuvwxyz" static void set_subcommand_option (enum subcommand subcommand) *************** *** 805,810 **** --- 808,817 ---- case 'X': exclude_option = 1; add_exclude_file (optarg); + break; + + case 'y': + set_use_compress_program_option ("bzip2"); break; case 'z': </verb> <sect>¨Ï¥Î bzip2 ¨Ó°t¦X less <p>°¨¤W¸ÑÀ£ÁY bzip2 ÀÉ¡A¨Ò¦p¡A¦b¤£¥²¥ý bunzip2 Àɮתº«e´£¤U§Y¥i¥Î "less" ¨ì¥¦­Ì¨­¤W¡A§A¥i¥H°µ­Ó lesspipe.sh (man less)¡A¹³¤U­±¡G <verb> #!/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 tzvvf - ;; #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 </verb> <sect>¨Ï¥Î bzip2 ¨Óµ²¦X emacs <sect1>¬°¨C­Ó¤H§ïÅÜ emacs: <p>§Ú¼g¤F¤U­±ªºµ¹ jka-compr.el ¥Îªº­×¸É¡A¥¦·|¥[¤J bzip2 ¦¨¬°¦Û°ÊÀ£ÁY¼Ò¦¡¡C <p><bf>°£¥~±ø´Ú:</bf> §Ú¥u¦b emacs-20.2¤W¸Õ¹L³o­Ó¡A¦ý¬O§Ú¤]§ä¤£¨ì¦³ Ô£»ò²z¥Ñ¨Ó¬Û«H¦P¼Ëªº¤èªk«o¤£¯à¦b¨ä¥Lª©¥»¤W¨Ï¥Îªº¡C <p>¨Ï¥Î¥¦¡A <enum> <item>¨ì emacs-20.2/lisp ­ì©lµ{¦¡½X¥Ø¿ýùØ (¬Ý§A¦b­þ¨à untarred ¥¦ªº) <item>§â¤U­±ªº­×¸É°µ¦¨¥s jka-compr.el.diff ªºÀÉ®×(¥þ©ñ¦b³oÀÉ®×ùØ )¡C <item>µM«á°õ¦æ <tscreen><verb> patch < jka-compr.el.diff </verb></tscreen> <item>±Ò°Ê emacs¡A¦A°õ¦æ <tscreen><verb> M-x byte-compile-file jka-compr.el </verb></tscreen> <item>Â÷¶} emacs¡C <item>§â¥¦­ì¨Óªº jka-compr.elc ©ñ¨ì¦w¥þªº¦a¤è¥H¨¾¦³¯ä¦ä®É³Æ¥Î¡C <item>¥Î·sªº jka-compr.elc¨Ó¥N´À¥¦¡C <item>¦n¦nª±§a! </enum> <verb> --- 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 http://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") </verb> <sect1>¬°¬Y¤H§ïÅÜ emacs: <p> ³o¦¸­nÁÂÁ Ulrik Dickow, <url url="mailto:ukdATkampsax.dk" name="ukd@kampsax.dk">¡A¥L¬OKampsax Technologyªº¨t²Îµ{¦¡³]­p®v : ¬°¤FÅý«D sysadmin ªºªB¤Í¥i¥H¦Û°Ê¦a¨Ï¥Î bzip2¡A¥u»Ý¦b§Aªº .emacs ÀÉ®×ùØ¥[¤W¤U¦CªFªF¡C <verb> ;; 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) </verb> <sect>¥Î bzip2 ¨Ó°t¦X wu-ftpd <p> ·PÁ Arnaud Launay ³o«h¸`¬ÙÀW¼eªº¯µ³Z¡C¤U­±ªº¤º®eÀ³¸Ó¬O©ñ¨ì /etc/ftpconversions ùØ­±¨Ó¹F¦¨¥H bzip2 ¨Ó°µ§Y®ÉÀ£ÁY¤Î¸ÑÀ£ÁY ¡C½Ð½T»{¸ô®| (¹³ /bin/compress) ­n¥¿½T¡C <verb> :.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 </verb> <sect>¨Ï¥Î bzip2 ¨Ó°t¦X grep <p>¤U­±ªº¤½¥Îµ{¦¡¡A§ÚºÞ¥¦¥s bgrep¡A¨Æ¹ê¤W¬O§â¦ñÀH¦b Linux ªº zgrep °µ­Ó¤p§ó§ï ¦Ó¤w¡C§A¥i¥H¨Ï¥Î¥¦¨Ó grep¡A¦Ó¤£»Ý¥ý bunzip2 ÀɮסC <verb> #!/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 </verb> <sect>bzip2 °t¦X X ¤Uªº Netscape ¨Ó¨Ï¥Î¡C <p> tenthumbs@cybernex.net »¡: <tscreen> §Ú§ä¨ì¤@­Ó¥i¥HÅý Linux Netscape ¨Ó¨Ï¥Î bzip2 °µ¬° Content-Encoding ´N¦p¦P¥¦¨Ï¥Î gzip ¤@¼Ë¡C§â¤U­±ªºªFªF¥[¨ì $HOME/.Xdefaults ©Î¬O $HOME/.Xresources <p> §Ú¨Ï¥Î -s ¿ï¶µ¡A¬O¦]¬°¿ï¾Ü©ñ±ó¸ÑÀ£ÁYªº³t«×¨Ó´«±o RAM ªº¦û¥Î¡C §A¥i¥H§â¥¦³]¦¨§A¦Û¤v­nªº¡C </tscreen> <verb> 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 </verb> <sect>¨Ï¥Î bzip2 ¨Ó¦AÀ£ÁY¨ä¥LªºÀ£ÁY®æ¦¡ <p>¤U­±ªº perl µ{¦¡·|§â¥H¤U¦CªºÀ£ÁY®æ¦¡ÀÉ (.tar.gz, .tgz. .tar.Z, ©M .Z for this iteration) ­«·s¥´¥]¦¨³Ì¨ÎªºÀ£ÁY­È¡C³o perl ­ì©lµ{¦¡³£¦³¥þ¤è¦ìªº¦n¤å¥ó ¨Ó»¡©ú¥¦°µ¤°»ò¥H¤Î¥¦¦p¦ó¿ì¨ìªº¡C <verb> #!/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; while(<*[Zz]>) { next if /^bzip2-0.1pl2.tar.gz$/; 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", " $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"; </verb> <sect>¤¤Ä¶¥» <p>ĶªÌµù: ­Y±zµo²{¥»¤å¥ó¤º®e¦³Â½Ä¶¤£¶¶ºZ©Î¿ù»~ªº¦a¤è¡A½Ð±z¨Ó«H§i¶D§Ú¡A¥H°µ§ó¥¿¡AÁÂÁ¡C ĶªÌ¹q¤l¶l¥ó <tt><htmlurl url="mailto:linuxer.bbs@cis.nctu.edu.tw" name="linuxer.bbs@cis.nctu.edu.tw"></tt> ©Î<htmlurl url="mailto:linux4tw@geocities.com" name="linux4tw@geocities.com"> <P> ͵ù¡G³o¥÷ HOWTO ¤å¥óªº¤¤¤åª©¥i¦b¥xÆW Linux ¨Ï¥ÎªÌ²Õ´¤Uªº¤¤¤å Linux ¤å¥ó­pµe<url url="http://www.linux.org.tw/CLDP/"><newline> ©Î¬O"Linux for Taiwan ¥xÆW¤Hªº Linux "<htmlurl url="http://members.xoom.com/linux4tw/" name="http://members.xoom.com/linux4tw/"> ¤U¨ú±o¡C </article>