zoukankan      html  css  js  c++  java
  • 老李分享:《Linux Shell脚本攻略》 要点(五)

    老李分享:《Linux Shell脚本攻略》 要点(五)

     

    //1、打包、解包

    [root@localhost program_test]# tar -cf output.tar 11.txt 22.txt 33.txt 

    [root@localhost program_test]# tar -xf output.tar -C ./tar-file/  //-C指定要提取到哪个路径?

    //列举出归档文件中的内容

    [root@localhost program_test]# tar -tvf output2.tar 
    -rw-rw-r-- yy/yy      101843 2014-12-18 07:40 33.txt
    drwxrwxr-x yy/yy           0 2014-12-31 18:11 abc/
    -rw-rw-r-- yy/yy           0 2014-12-31 18:11 abc/def

    //

    [root@localhost program_test]# tar -tf output.tar 
    11.txt
    22.txt
    33.txt
    33.txt
    abc/
    abc/def

    //删除给定归档文件中的文件
    [root@localhost program_test]# tar -f output.tar  --delete 33.txt
    [root@localhost program_test]# tar -tf output.tar 
    11.txt
    22.txt
    abc/
    abc/def

     

    2、压缩

    //批量打包和压缩的实现

    [root@localhost touch_more]# cat gzip_all_files.sh

    #!/bin/bash

    textfiles=`ls | grep ".txt" | xargs`

    echo $textfiles

    for textfile in $textfiles;

    do

            tar -rvf archive.tar $textfile  //以追加的形式打包文件.

    done

    gzip archive.tar  //压缩归档文件

  • 相关阅读:
    雅虎军规34条 (一)
    jetty和tomcat的区别
    Jsp--9大内置对象
    java 重定向和转发的区别
    layer弹出层
    html 锚点
    css绘制三角形
    原生js下拉菜单联动
    layui省市区下拉菜单三级联动
    tp5时间格式转换
  • 原文地址:https://www.cnblogs.com/poptest/p/4988966.html
Copyright © 2011-2022 走看看