tar

解压的时候重命名

例子: 方法一:同时使用-C和--strip-components参数

-C, --directory=DIR Change to DIR before performing any operations. This option is order-sensitive, i.e. it affects all options that follow.

--strip-components=1 Strip NUMBER leading components from file names on extraction.

mkdir FOLDER
# 解压远程压缩文件
curl -L ’remote_tar_file' | tar -xz - -C FOLDER --strip-components=1

# 解压本地压缩文件
tar -xz FILENAME -C FOLDER --strip-components=1

方法二:使用--transform参数 例如,我要给2.6.38打个补丁,把linux-2.6.38内核解压到linux-2.6.38.1目录

tar -xjf linux-2.6.38.tar.bz2 --transform 's/linux-2.6.38/linux-2.6.38.1/'

results matching ""

    No results matching ""