zoukankan      html  css  js  c++  java
  • tar命令中的 -C 作用

    我用这个命令:tar zcvf chao.tar.gz /chao/*  打包文件的时候,在压缩包里把  /chao/这个路径也打包进去了。

    [root@yunwei-test chao]# ls /chao/
    01.txt  02.txt  03.txt  04.txt  05.txt  06.txt  07.txt  08.txt  09.txt  10.txt
    
    [root@yunwei-test chao]# tar zcvf /tar/chao.tar.gz /chao/*
    tar: Removing leading `/' from member names
    /chao/01.txt
    /chao/02.txt
    /chao/03.txt
    /chao/04.txt
    /chao/05.txt
    /chao/06.txt
    /chao/07.txt
    /chao/08.txt
    /chao/09.txt
    /chao/10.txt
    
    [root@yunwei-test chao]# ls /tar/
    chao.tar.gz
    
    #解压
    [root@yunwei-test chao]# cd /tar/
    [root@yunwei-test tar]# ls
    chao.tar.gz
    [root@yunwei-test tar]# tar xf chao.tar.gz 
    [root@yunwei-test tar]# ls
    chao  chao.tar.gz
    [root@yunwei-test tar]# cd chao/
    [root@yunwei-test chao]# ls
    01.txt  02.txt  03.txt  04.txt  05.txt  06.txt  07.txt  08.txt  09.txt  10.txt

    我想不要路径,我不想切换目录过去,而又只想打包指定目录下的文件。 使用 -C 参数。 

    ##打包
    [root@yunwei-test chao]# tar zcvf /tar/chao.tar.gz -C /chao . ./ ./01.txt ./02.txt ./03.txt ./04.txt ./05.txt ./06.txt ./07.txt ./08.txt ./09.txt ./10.txt [root@yunwei-test chao]# ls /tar/ chao.tar.gz [root@yunwei-test chao]# cd /tar/ [root@yunwei-test tar]# ls chao.tar.gz

    #解压 [root@yunwei
    -test tar]# tar xvf chao.tar.gz ./ ./01.txt ./02.txt ./03.txt ./04.txt ./05.txt ./06.txt ./07.txt ./08.txt ./09.txt ./10.txt [root@yunwei-test tar]# ls 01.txt 02.txt 03.txt 04.txt 05.txt 06.txt 07.txt 08.txt 09.txt 10.txt chao.tar.gz

     ##在解压的时候 -C 是解压到指定目录中。

  • 相关阅读:
    BZOJ 2456: mode
    替罪羊树(模板)
    LUOGU P4168 [Violet]蒲公英
    洛谷题目统计爬虫
    LUOGU P3819 松江1843路
    bzoj 2946 [Poi2000]公共串——后缀自动机
    bzoj 4032 [HEOI2015]最短不公共子串——后缀自动机
    bzoj 2555 SubString——后缀自动机+LCT
    洛谷 3804 【模板】后缀自动机
    洛谷 4106 / bzoj 3614 [HEOI2014]逻辑翻译——思路+类似FWT
  • 原文地址:https://www.cnblogs.com/root0/p/9681125.html
Copyright © 2011-2022 走看看