以下是CentOS中extract(通常指tar等压缩工具的提取操作)的使用技巧:
.tar.gz文件:tar -xzvf archive.tar.gz.zip文件:unzip archive.zip(需先安装unzip)tar -xzvf archive.tar.gz -C /path/to/dir--exclude='*.log'(排除所有.log文件)--include='*.txt'(仅提取.txt文件)--transform 's/old_name/new_name/'(修改文件名)--strip-components=1(去掉压缩包的第一层目录)--wildcards '*.conf'(提取所有.conf文件)for循环处理,如for file in *.tar.gz; do tar -xzvf "$file"; done#!/bin/bash
tar -xzvf "$1" -C /target/dir && echo "解压成功"
sudo yum install tar unzip unrar-f参数会强制覆盖参考来源: