加入收藏 | 设为首页 | 会员中心 | 我要投稿 我爱制作网_池州站长网 (https://www.0566zz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 服务器 > 搭建环境 > Linux > 正文

Linux下各种压缩解压缩命令整理

发布时间:2023-02-18 13:42:24 所属栏目:Linux 来源:
导读:  命令安装一般安装

  yum install bzip2 gzip xz tar zip -y

  yum install -y

  rar/lzip特殊安装

  压缩解压缩.bz2

  bzip2 命令操作文件之后会删除删文件

  ## compress
  命令安装一般安装
 
  yum install bzip2 gzip xz tar zip -y
 
  yum install -y
 
  rar/lzip特殊安装
 
  压缩解压缩.bz2
 
  bzip2 命令操作文件之后会删除删文件
 
  ## compress
  bzip2 filename.txt
  ## uncomress
  bzip2 -d filename.txt.bz2
  bunzip2 filename.txt.bz2
  bzcat 可以参看压缩文件内容
 
  .gz
 
  gzip 命令操作文件之后会删除删文件
 
  # compress
  gzip filename.txt
  ## uncompress
  gzip -d filename.txt.gz
  gunzip filename.txt.gz
  .xz
 
  ## compress
  xz -[z] filename
  ## uncompress
  unxz filename.xz
  xz -d filename.xz
  xzcat 可以查看xz压缩的文件
 
  tar
 
  tar是打包解包工具,不是压缩解压缩工具
 
  ## pack
  tar -cvf filename.tar file_or_DirName
  ## unpack
  tar -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
 
  ## compress
  zip file.zip file_or_folder
  ## uncompress
  unzip 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.gz
  mbit=$(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 unpack
  uLog "uncompress and unpack ${package}"
  tar -zxvf ${package}
  ## install
  uLog "installing"
  cd rar
  make
  ## delete old unuseful folder
  uLog "delete old unuseful folder"
  cd ..
  rm -rf rar
  rar 压缩和解压缩
 
  ## compress
  rar a file.rar file_or_folder
  ## uncompress
  rar x file.rar
  unrar e file.rar
  可以直接输入rar或者unrar回车查看具体用法
 
  .Z
 
  .Z 是 compress命令的后缀
 
  ## compress
  compress filename
  ## uncompress
  uncompress filename.Z
  .lz
 
  lzip 的安装方式目前只能采用源码安装的方式linux 压缩,这里附 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.gz
  package="lzlib-1.8.tar.gz"
  # uncompress and unpack
  uLog "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
  ## delete
  uLog "delete temp folder"
  cd ..
  rm -rf lzlib-1.8
  lzip 压缩解压缩
 
  ## compress
  lzip filename
  ## uncompress
  lzip -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:14
  root@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:19
  root@pts/4 $ tar -tf lzip.tar.lz
  file1
  file2
  file3
 

(编辑:我爱制作网_池州站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!