Bzip2 Howto §@ªÌ: David Fetter, [1]dfetter@best.com ĶªÌ: Á±X¤¤ HSIEH KUN-CHUNG, ¥xÆW ¤¤µØ¥Á°ê Taiwan, Republic of China (NOT People's Republic of China) (¹q¤l¶l¥ó [2]linuxer.bbs@cis.nctu.edu.tw ©Î [3]linux4tw@geocities.com ºô­¶ "Linux for Taiwan ¥xÆW¤Hªº Linux" [4]http://members.xoom.com/linux4tw/ ª©¥» v1.92¡A1998¦~ 8¤ë18¤é _________________________________________________________________ ³o¥÷¤å¥ó¦b±Ð§A¦p¦ó¨Ï¥Î·sªº bzip2 À£ÁYµ{¦¡¡C¥Ø«eªº sgml ª©¥»³Q©ñ¦b EURO [5]³oùØ¡AÁÙ¦³ "§@ªÌ¥Îªº" sgml ÀÉ©ñ¦b [6]³o¨à¡C _________________________________________________________________ 1. ²¤¶ * 1.1 ªu­²¾ú¥v 2. ¨ú±o bzip2 * 2.1 Bzip2-HOWTO ¦UºØ»y¨¥ª©¥» * 2.2 ¨ú±o bzip2 ¥¼½sĶªº¤G¶i¦ìÀÉ * 2.3 ¨ú±o bzip2 ­ì©lµ{¦¡ * 2.4 ½sĶ bzip2 µ¹§Aªº¾÷¾¹¨Ï¥Î 3. ¨Ï¥Î bzip2 4. °t¦X tar¨Ó¨Ï¥Î bzip2 * 4.1 ®e©ö³]¥ß: * 4.2 ®e©ö³]¥ß¡A®e©ö¨Ï¥Î¡A¤£»Ý­n root ªº¯SÅv: * 4.3 ¦P¼Ë¬O®e©ö¨Ï¥Î¡A¦ý»Ý­n root ¨Ó¦s¨ú¡C 5. ¨Ï¥Î bzip2 ¨Ó°t¦X less 6. ¨Ï¥Î bzip2 ¨Óµ²¦X emacs * 6.1 ¬°¨C­Ó¤H§ïÅÜ emacs: * 6.2 ¬°¬Y¤H§ïÅÜ emacs: 7. ¥Î bzip2 ¨Ó°t¦X wu-ftpd 8. ¨Ï¥Î bzip2 ¨Ó°t¦X grep 9. bzip2 °t¦X X ¤Uªº Netscape ¨Ó¨Ï¥Î¡C 10. ¨Ï¥Î bzip2 ¨Ó¦AÀ£ÁY¨ä¥LªºÀ£ÁY®æ¦¡ 11. ¤¤Ä¶¥» _________________________________________________________________ 1. ²¤¶ Bzip2 ¬O­Ó«Ü´ÎªºÀ£ÁY¸ê®Æ¥Î¤§·s«¬ºtºâªk¡C¤j­P¤W¯à°÷¹F¨ì¥H¥¦ªº¹ï¤â gzip ©Ò²£¥XªºÀɮפ§ 60-70% ¥ª¥kªºÀ£ÁY²v¡C ³o¥÷¤å¥ó±N±Ð§A´X­Ó bzip2 ªºÀ³¥Î³nÅé¡C ¥»¤å¥óªº¥¼¨Óª©±N·|°Q½×§Y±N¥X²{ªº bzip2 µ{¦¡®w¡A¸Óµ{¦¡®w ­ìbzip2 ªº§@ªÌ [7]Julian Seward ´y­z¦p¤U: ²{¦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 ¥»¤å¥óªº¥¼¨Óª©¥»¤]·|¥]§t¬O§_À³¸Ó (¥H¤Î¦p¦ó)Åý Linux kernel ¨Ï¥Î bzip2¤§ ijÃDªºµ²½×¡C 1.1 ªu­²¾ú¥v v1.92§ó·s [8]¨ú±o bzip2 ¤G¶i¦ìµ{¦¡½X ³¹¸`¡A¥[¤J S.u.S.E.ªº¡C v1.91 ¦b [9]¨Ï¥Î bzip2 °t¦X tar ¨º³¹ùØ­×¥¿¤@­Ó½d¨Ò¥H¤Î §Ë²M·¡¤@¨Ç shell ¥y¤l ¡C·PÁ Alessandro Rubini¡C §ó·s buzzit ¤u¨ã¤£·|¥h stomp ­ì¨Óªº bzip2 À£ÁYÀÉ¡C ·s¼W bgrep, ¹³ zgrep-ªº¤u¨ã¡C v1.9 ¼á²M gcc 2.7.* ªº°ÝÃD¡C·PÁ Ulrik Dickow ªº¼ö¤ß«ü¥X¡C ¥[¤J Leonard Jean-Marc «Ü´Îªº°t¦X tar ¥[¤W Linus Ãkerlund ªº·ç¨å¤åª©¥»¡C ¨Ì·Ó Arnaud Launay ªº«Øij­×¥¿¤F wu-ftpd ³¹¸` §âĶ¤å©ñ¨ì¥¦­Ì¦Û¤vªº¦ì³¹¸`¤W¡C v1.8 §â buzzit ©M tar.diff ©ñ¨ì sgml ¤å¥óùØ¥¦­ÌÀ³¸Ó³Q©ñ¸mªº¦a¤è¡C ­×¥¿«÷¦r»P ®æ¦¡¡C·PÁ Arnaud Launay ªº¨ó§U§Ú­×¥¿³o¥÷¤å¥ó¡C:-) ±þ±¼ xv ­pµe¡A¦]¦¹¤j®a¤£·P¿³½ì¡C ¥[¤W teasers ¬°¥»¤å¥óªº¥¼¨Óª©¥»¡C v1.7 ¥[¤J buzzit ¤½¥Îµ{¦¡¡C­×¥¿¹ï gnu tar ªº­×¸É¡C v1.6 ¥[¤J TenThumbs ªº Netscape ­P¯àªÌ¡C ¥H¤Î¨Ì¾Ú¥¦ªº«Øij§ó§ï lesspipe.sh ¡C¥¦²{¦b¥i¥H¤u§@ªº§ó¦n¤F¡C v1.5 ¥[¤J Arnaud Launay ªºªk¤åĶ¥»¡A¥H¤Î¥Lªº wu-ftpd ÀÉ¡C v1.4 ¥[¤J Tetsu Isaji ªº¤é¤åĶ¥»¡C v1.3 ¥[¤J Ulrik Dickow µ¹ 19.30 ©Î§ó°ªª©¥»¥Îªº .emacs ÀÉ¡ (ÁÙ¦³­×¥¿µ¹ emacs¥Îªº jka-compr.el ­×¸ÉÀÉ¡CÁV¤F! Bzip2 ÁÙ¨S¦³(?) "append" ªººX¼Ð¿ï¶µ¡C) v1.2 ¥[¤J¹ï emacs ªº­×¸É¡AÅý¥¦¥i¥H¦Û°Ê¦a¿ìÃÑ¥X .bz2 ÀÉ¡C v1.1 ¥[¤J¹ï emacs v1.0 ²Ä¤@¦^¦X¡C 2. ¨ú±o bzip2 Bzip2 ªº¥Dºô­¶¦b [10]­^°êªº¥Dºô¯¸¡C ¬ü°êªº¬M®g¯¸¦b [11]³oùØ¡C§A¤]¥i¥H¦b Red Hat ªºftp ¯¸ùØ [12]§ä¨ì¡C 2.1 Bzip2-HOWTO ¦UºØ»y¨¥ª©¥» »¡ªk»yªº¤H¥i¥H¬Ý¬Ý Arnaud Launay ªºªk¤å¤å¥ó¡C ºô­¶ª©¥»¦b [13]³oùØ¡A§A¥i ¥H¥Î ftp [14]¨Ó¨ú±o §A¥i¥H¥Î [15]¹q¤l¶l¥ó¨Ó³sµ¸Arnaud »¡¤é»yªº¤H¥i¥H¬Ý¬Ý Tetsu Isajiªº [16]¤é¤åĶ¥»¡C §A¥i¥H¥Î¤WIsajiªº [17] ºô¯¸¡A©Î¬O¥Î [18]¹q¤l¶l¥óªº¤è¦¡¡C »¡·ç¨å»yªºªB¤Í¥i¥H°Ñ¾\ Linus Ãkerlund ªº·ç¨å¤åĶ¥» [19]«ö³o¡C§A¥i¥H¥Î [20]¹q¤l¶l¥ó »P Linus ³sµ¸¡C 2.2 ¨ú±o bzip2 ¥¼½sĶªº¤G¶i¦ìÀÉ ¬d¤@¤U¥Dºô¯¸¡C Debian ªºIntel ¤G¶i¦ìµ{¦¡½X¦b [21]³oùØ¡C Red Hatªº alpha ¤G¶i¦ìµ{¦¡½X¦b [22]³oùØ¡C Red Hatªº Intel ¤G¶i¦ìµ{¦¡½X¦b [23]³oùØ¡C Red Hatªº SPARC ¤G¶i¦ìµ{¦¡½X¦b [24]³oùØ¡C Slackwareªº Intel ¤G¶i¦ìµ{¦¡½X¦b [25]³oùØ¡C S.u.S.E.ªº Intel ¤G¶i¦ìµ{¦¡½X¦b [26]³oùØ¡C §A¤]¥i¥H±q³\¦h¬ÛÃþ¦üªº¬M®g¯¸±o¨ú±oÀɮסC 2.3 ¨ú±o bzip2 ­ì©lµ{¦¡ §A¥i¥H±q©x¤èªººô¯¸ (¬Ý [27]Getting Bzip2 ¡A©Î¬O Red Hat ¤]¦³ [28]¥¦)¡C 2.4 ½sĶ bzip2 µ¹§Aªº¾÷¾¹¨Ï¥Î ¦pªG§A¦³ gcc 2.7.*¡A±N¤U­±³o¦æ CFLAGS = -O3 -fomit-frame-pointer -funroll-loops §ï¦¨ CFLAGS = -O2 -fomit-frame-pointer ¤]´N¬O¡A§â -O2 §ï¦¨ -O3 ¨Ã§â -funroll-loops§R±¼¡C§A¤]¥i¥H¥[¤J¥ô¦ó§A¦b½s Ķ kernel ®Éªº -m* ºX¼Ð (¨Ò¦p¹³ -m486)¡C Áק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 ¤§«á¡A¥u»Ý make ¥¦¡AµM«á¨Ì·Ó README ¨Ó¦w¸Ë¥¦¡C 3. ¨Ï¥Î bzip2 ½Ð°Ñ¾\«Ü´Îªº¤â¥U :) 4. °t¦X tar¨Ó¨Ï¥Î bzip2 ¤U­±¦³¤TºØ°t¦X tar ¨Ï¥Î bzip2 ªº¤èªk¡A¤]´N¬O 4.1 ®e©ö³]¥ß: ³o­Ó¤èªk¸ò¥»´N¤£¥²°µ³]©w¡C°õ¦æ¸Ñ¶}bzip2'd ªº tar¥]»q¡A ¦b²{¦æ¥Ø¿ý©³¤U¦³ ­Ó foo.tar.bz2¡A°õ¦æ /path/to/bzip2 -cd foo.tar.bz2 | tar xf - ¦¨¥\¤F¡A¦ý¥i¯à¦³±`»Ý¿é¤Jªº¤p¯ÊÂI¡C 4.2 ®e©ö³]¥ß¡A®e©ö¨Ï¥Î¡A¤£»Ý­n root ªº¯SÅv: ·PÁ [29]Leonard Jean-Marc °^Äm³o­Ó¤p§Þ¥©¡C¤]ÁÂÁ [30]Alessandro Rubini ±q cshùؤÀÃþ ¥X bash ªº¡C ¦b§Aªº .bashrcùØ¡A§A¥i¥H¥[¤J¹³¤U­±³o¦æ: alias btar='tar --use-compress-program /usr/local/bin/bzip2 ' ¦b§Aªº .tcshrc ©Î .cshrcùØ¡A¥i¥Î¤U­±³o¦æ¬Û¦Pªº: alias btar 'tar --use-compress-program /usr/local/bin/bzip2' 4.3 ¦P¼Ë¬O®e©ö¨Ï¥Î¡A¦ý»Ý­n root ¨Ó¦s¨ú¡C ¥Î¤U­±¨Ó¤èªk¨Ó­×¸É gnu tar 1.12¡G cd tar-1.12/src; patch < /path/to/tar.diff ½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»Ý tar xyf foo.tar.bz2 ¨ÓÀ£ÁYÀɮסC ­n»s§@·sªºÀ£ÁYÀÉ¡A¦P¼Ë¦a: tar cyf foo.tar.bz2 ÀɦW1 ÀɦW2 ÀɦW3...¥Ø¿ý1 ¥Ø¿ý2... ¤U­±¬O­×¸Éªº¦a¤è: *** 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': 5. ¨Ï¥Î bzip2 ¨Ó°t¦X less °¨¤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 #!/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 sr c 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 6. ¨Ï¥Î bzip2 ¨Óµ²¦X emacs 6.1 ¬°¨C­Ó¤H§ïÅÜ emacs: §Ú¼g¤F¤U­±ªºµ¹ jka-compr.el ¥Îªº­×¸É¡A¥¦·|¥[¤J bzip2 ¦¨¬°¦Û°ÊÀ£ÁY¼Ò¦¡¡C °£¥~±ø´Ú: §Ú¥u¦b emacs-20.2¤W¸Õ¹L³o­Ó¡A¦ý¬O§Ú¤]§ä¤£¨ì¦³ Ô£»ò²z¥Ñ¨Ó¬Û«H ¦P¼Ëªº¤èªk«o¤£¯à¦b¨ä¥Lª©¥»¤W¨Ï¥Îªº¡C ¨Ï¥Î¥¦¡A 1. ¨ì emacs-20.2/lisp ­ì©lµ{¦¡½X¥Ø¿ýùØ (¬Ý§A¦b­þ¨à untarred ¥¦ªº) 2. §â¤U­±ªº­×¸É°µ¦¨¥s jka-compr.el.diff ªºÀÉ®×(¥þ©ñ¦b³oÀÉ®×ùØ )¡C 3. µM«á°õ¦æ patch < jka-compr.el.diff 4. ±Ò°Ê emacs¡A¦A°õ¦æ M-x byte-compile-file jka-compr.el 5. Â÷¶} emacs¡C 6. §â¥¦­ì¨Óªº jka-compr.elc ©ñ¨ì¦w¥þªº¦a¤è¥H¨¾¦³¯ä¦ä®É³Æ¥Î¡C 7. ¥Î·sªº jka-compr.elc¨Ó¥N´À¥¦¡C 8. ¦n¦nª±§a! --- 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") 6.2 ¬°¬Y¤H§ïÅÜ emacs: ³o¦¸­nÁÂÁ Ulrik Dickow, [31]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 ;; 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) 7. ¥Î bzip2 ¨Ó°t¦X wu-ftpd ·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 :.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 8. ¨Ï¥Î bzip2 ¨Ó°t¦X grep ¤U­±ªº¤½¥Îµ{¦¡¡A§ÚºÞ¥¦¥s bgrep¡A¨Æ¹ê¤W¬O§â¦ñÀH¦b Linux ªº zgrep °µ­Ó¤p §ó§ï ¦Ó¤w¡C§A¥i¥H¨Ï¥Î¥¦¨Ó grep¡A¦Ó¤£»Ý¥ý bunzip2 ÀɮסC #!/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 9. bzip2 °t¦X X ¤Uªº Netscape ¨Ó¨Ï¥Î¡C tenthumbs@cybernex.net »¡: §Ú§ä¨ì¤@­Ó¥i¥HÅý Linux Netscape ¨Ó¨Ï¥Î bzip2 °µ¬° Content-Encoding ´N¦p¦P¥¦¨Ï¥Î gzip ¤@¼Ë¡C§â¤U­±ªºªFªF¥[¨ì $HOME/.Xdefaults ©Î¬O $HOME/.Xresources §Ú¨Ï¥Î -s ¿ï¶µ¡A¬O¦]¬°¿ï¾Ü©ñ±ó¸ÑÀ£ÁYªº³t«×¨Ó´«±o RAM ªº¦û¥Î¡C §A¥i¥H §â¥¦³]¦¨§A¦Û¤v­nªº¡C 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 10. ¨Ï¥Î bzip2 ¨Ó¦AÀ£ÁY¨ä¥LªºÀ£ÁY®æ¦¡ ¤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 #!/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"; 11. ¤¤Ä¶¥» ĶªÌµù: ­Y±zµo²{¥»¤å¥ó¤º®e¦³Â½Ä¶¤£¶¶ºZ©Î¿ù»~ªº¦a¤è¡A½Ð±z¨Ó«H§i¶D§Ú¡A¥H °µ§ó¥¿¡AÁÂÁ¡C ĶªÌ¹q¤l¶l¥ó [32]linuxer.bbs@cis.nctu.edu.tw ©Î [33]linux4tw@geocities.com Ķµù¡G³o¥÷ HOWTO ¤å¥óªº¤¤¤åª©¥i¦b¥xÆW Linux ¨Ï¥ÎªÌ²Õ´¤Uªº¤¤¤å Linux ¤å ¥ó­pµe [34]http://www.linux.org.tw/CLDP/ ©Î¬O"Linux for Taiwan ¥xÆW¤Hªº Linux " [35]http://members.xoom.com/linux4tw/ ¤U¨ú±o¡C References 1. mailto:dfetter@best.com 2. mailto:linuxer.bbs@cis.nctu.edu.tw 3. mailto:linux4tw@geocities.com 4. http://members.xoom.com/linux4tw/ 5. file://localhost/tmp/zh-sgmltools.24769/Bzip2-HOWTO.sgml 6. http://www.best.com/~dfetter/Bzip2-HOWTO/Bzip2-HOWTO.sgml 7. mailto:Julian_Seward@muraroa.demon.co.uk 8. file://localhost/tmp/zh-sgmltools.24769/Bzip2.txt.html#bzip2-binaries 9. file://localhost/tmp/zh-sgmltools.24769/Bzip2.txt.html#bzip2-with-tar 10. http://www.muraroa.demon.co.uk/ 11. http://www.digistar.com/bzip2/index.html 12. ftp://ftp.redhat.com/pub/contrib 13. http://www.freenix.fr/linux/HOWTO/mini/Bzip2.html 14. ftp://ftp.lip6.fr/pub/linux/french/docs/HOWTO/mini/Bzip2.gz 15. mailto:zoro@mygale.org 16. http://jf.gee.kyoto-u.ac.jp/JF/JF.html 17. http://www2s.biglobe.ne.jp/~kaien/ 18. mailto:isaji@mxu.meshnet.or.jp 19. http://user.tninet.se/~uxm165t/linux_doc.html 20. mailto:uxm165t@tninet.se 21. ftp://ftp.debian.org/debian/dists/stable/main/binary-i386/utils/bzip2_0.1pl2-5.deb 22. ftp://ftp.redhat.com/pub/redhat/redhat-5.1/alpha/RedHat/RPMS/bzip2-0.1pl2-1.alpha.rpm 23. ftp://ftp.redhat.com/pub/redhat/redhat-5.1/i386/RedHat/RPMS/bzip2-0.1pl2-1.i386.rpm 24. ftp://ftp.redhat.com/pub/redhat/redhat-5.1/sparc/RedHat/RPMS/bzip2-0.1pl2-1.sparc.rpm 25. ftp://www.cdrom.com/pub/linux/slackware-3.5/slakware/a1/bzip2.tgz 26. ftp://ftp.suse.com/pub/SuSE-Linux/5.2/suse/ap1/bzip.rpm 27. file://localhost/tmp/zh-sgmltools.24769/Bzip2.txt.html#get-bzip2 28. ftp://ftp.redhat.com/pub/contrib/SRPMS/bzip2-0.1pl2-1.src.rpm 29. mailto:leonard@sct1.is.belgacom.be 30. mailto:rubini@morgana.systemy.it 31. mailto:ukdATkampsax.dk 32. mailto:linuxer.bbs@cis.nctu.edu.tw 33. mailto:linux4tw@geocities.com 34. http://www.linux.org.tw/CLDP/ 35. http://members.xoom.com/linux4tw/