Bzip2 Howto( 三 )



 tar cyf foo.tar.bz2 档名1 档名2 档名3...目录1 目录2...

下面是修补的地方:

*** 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 ----
PATTERNat list/extract time, a globbing PATTERNn
-o, --old-archive, --portability write a V7 format archiven
--posixwrite a POSIX conformant archiven
-y, --bzip2, --bunzip2 filter the archive through bzip2n
-z, --gzip, --ungzip filter the archive through gzipn
-Z, --compress, --uncompress filter the archive through compressn
--use-compress-program=PROGfilter through PROG (must accept -d)n"),
***************
*** 448,454 ****
 Yper-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 ----
 Yper-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 来配合 less
马上解压缩 bzip2 档,例如,在不必先 bunzip2 档案的前提下即可用 "less" 到它们身上,你可以做个 lesspipe.sh (man less),像下面:

#!/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 $12>/dev/null ;; # View compressed files correctly
*.Z) gzip -dc $12>/dev/null 
*.z) gzip -dc $12>/dev/null 
*.gz) gzip -dc $12>/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"

推荐阅读