|
发表于 2003-10-25 22:42:19
|
显示全部楼层
回复: 如何用shell替代gzip?
最初由 sukur 发表
我想在执行gzip前cp一个文件到当前目录,然后再调用gzip
假设脚本文件为test.sh
执行
./test -d xxx.gz
就会实际等于
cp x.dat ./
gzip -d xxx.gz
之所以这样是因为c++builderx在安装的时候,安装包里的java vm包是坏的,我希望在安装程序调用gzip前自动拷贝一个vm包到其临时安装目录,不知能否做到?
另外请问一下gzip文件在哪个目录下?我想给它改名,可我只在/usr/bin下找到它的一个符号连接
试试这个,在redhat 9.0 实验通过
[PHP]#!/bin/bash
#cg-> cp and gzip
#this script can cp a file to a directory and gzip it.
ARG=$1
DFILE=$3
FPATH=$2
usage()
{
echo "Usage:dialog <option> [srouce file path] [copy to which path]
option: it can use command "gzip" options."
exit 1
}
#main
if [ $# -ne 3 ];then
usage
fi
cp $FPATH $DFILE >/dev/null 2>&1
if [ $? -ne 0 ];then
echo "Can't copy file,something wrong,plese check it."
exit 1
fi
CPATH=`pwd`
cd $DFILE
gzip $ARG `basename $FPATH`
if [ $? -ne 0 ];then
cd $CPATH
echo "Can't uncompress $DFILE,please check it."
exit 1
fi
echo "$FPATH have been copy to $DFILE and umcopress."
cd $CPATH
exit 0
[/PHP]
举个例子:把/root/test.gz 复制到/tmp目录下并解压为test
可以这样做cg -d /root/test.gz /tmp |
|