linux压缩命令xz,Linux下各种压缩解压缩命令整理

命令安装

一般安装yum install bzip2 gzip xz tar zip -y

yum install -y

rar/lzip特殊安装

压缩解压缩

.bz2

bzip2 命令操作文件之后会删除删文件## compressbzip2 filename.txt## uncomressbzip2 -d filename.txt.bz2bunzip2 filename.txt.bz2

bzcat 可以参看压缩文件内容

.gz

gzip 命令操作文件之后会删除删文件# compressgzip filename.txt## uncompressgzip -d filename.txt.gzgunzip filename.txt.gz

.xz## compressxz -[z] filename## uncompressunxz filename.xzxz -d filename.xz

xzcat 可以查看xz压缩的文件

tar

tar是打包解包工具,不是压缩解压缩工具## packtar -cvf filename.tar file_or_DirName## unpacktar -xvf filename.tar

tar 常用参数解析-c 创建新的tar包

-x 从tar包中解析或者提取文件

-v 创建或者解析时显示详细的文件

-f 生成的tar包文件或者从哪个tar包文件提取 `-f`是必须的,一般和-c或者-x等组合

-t 列举tar包中都有哪些文件

-j  打包并压缩成 `bzip2` 文件`tar.bz2`-J  打包并压缩成 `xz` 文件`tar.xz`-z  打包并压缩成 `gzip` 文件 `tar.gz`-Z  打包并压缩成 `compress` 文件`tar.Z`

.zip## compresszip file.zip file_or_folder## uncompressunzip filename.zip

.rar

rar的安装方式目前只能采用源码安装的方式,这里附rar shell安装脚本#!/usr/bin/env bash# -*- coding: utf-8 -*-#Filename:  /devOps/shell/common/installRar.sh#Author:        Liuchao#Email:     137642091@qq.com#Date:      2016-06-07#Desc:      Linux下安装 rar 命令#source /devOps/shell/common/functions

## wget http://www.rarsoft.com/rar/rarlinux-x64-5.4.b2.tar.gz## wget http://www.rarsoft.com/rar/rarlinux-5.4.b2.tar.gzmbit=$(uname -m|awk -F '_' '{print $2}')if [ "$mbit" == "64" ]then

package="rarlinux-x64-5.4.b2.tar.gz"else

package="rarlinux-5.4.b2.tar.gz"fi## uncompress and unpackuLog "uncompress and unpack ${package}"tar -zxvf ${package}## install uLog "installing"cd rar

make

## delete old unuseful folderuLog "delete old unuseful folder"cd ..

rm -rf rar

rar 压缩和解压缩## compressrar a file.rar file_or_folder## uncompressrar x file.rarunrar e file.rar

可以直接输入rar或者unrar回车查看具体用法

.Z

.Z 是 compress命令的后缀## compresscompress filename## uncompressuncompress filename.Z

.lz

lzip 的安装方式目前只能采用源码安装的方式,这里附 lzip shell安装脚本#!/usr/bin/env bash# -*- coding: utf-8 -*-#Filename:  installLzip.sh#Author:        Liuchao#Email:     137642091@qq.com#Date:      2016-06-07#Desc:      Linux下安装 lzip 命令#source /devOps/shell/common/functions

# http://download.savannah.gnu.org/releases/lzip/lzlib/lzlib-1.8.tar.gzpackage="lzlib-1.8.tar.gz"# uncompress and unpackuLog "unpack ..."tar -zxvf $package## compile and install cd lzlib-1.8

uLog "configure ..."./configure

uLog "make"make

uLog "make isntall"make install

uLog "make install-as-lzip"make install-as-lzip## deleteuLog "delete temp folder"cd ..

rm -rf lzlib-1.8

lzip 压缩解压缩## compresslzip filename## uncompresslzip -d filename.lz

lzip 可以通过--lzip 参数和tar命令结合root@pts/4 $ tar --lzip -cvf  lzip.tar.lz file*

file1

file2

file3

Dev-web-solr [/tmp/liuchao] 2016-06-07 16:15:14root@pts/4 $ ls -l

total 12-rw-r--r-- 1 root root   0 Jun  7 16:14 file1

-rw-r--r-- 1 root root   0 Jun  7 16:14 file2

-rw-r--r-- 1 root root   0 Jun  7 16:14 file3

-rw-r--r-- 1 root root 147 Jun  7 16:15 lzip.tar.lz

Dev-web-solr [/tmp/liuchao] 2016-06-07 16:15:19root@pts/4 $ tar -tf lzip.tar.lz

file1

file2

file3

参考

作者:全栈运维

链接:https://www.jianshu.com/p/eb76dfbe96a5

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值