這篇文章給大家介紹如何進(jìn)行tar打包且排除某個(gè)文件,內(nèi)容非常詳細(xì),感興趣的小伙伴們可以參考借鑒,希望對大家能有所幫助。

| 有tar打包,有時(shí)候需要排除某個(gè)文件,本文檔提供兩種方法來操作。 |
方法一
[root@system1 testdir]# touch 1 2 3 4 5 6 7 b [root@system1 testdir]# ls 1 2 3 4 5 6 7 b [root@system1 testdir]# tar zcvf a.tar.gz ./* --exclude b #排除b文件 ./1 ./2 ./3 ./4 ./5 ./6 ./7 [root@system1 testdir]# ls 1 2 3 4 5 6 7 a.tar.gz b [root@system1 testdir]# mv a.tar.gz /tmp/test [root@system1 testdir]# ls 1 2 3 4 5 6 7 b [root@system1 testdir]# cd .. [root@system1 tmp]# cd test [root@system1 test]# ls a.tar.gz [root@system1 test]# tar -xvf a.tar.gz ./1 ./2 ./3 ./4 ./5 ./6 ./7 [root@system1 test]# ls 1 2 3 4 5 6 7 a.tar.gz
方法二
[root@system1 testdir]# ls 1 2 3 4 5 6 7 b [root@system1 testdir]# find ./ -type f ! -name 'b' | xargs tar caf a.tar.gz #排除b文件 [root@system1 testdir]# ls 1 2 3 4 5 6 7 a.tar.gz b [root@system1 testdir]# mv a.tar.gz /tmp/test [root@system1 testdir]# cd /tmp/test [root@system1 test]# ls a.tar.gz [root@system1 test]# tar -xvf a.tar.gz ./1 ./2 ./3 ./4 ./5 ./6 ./7 [root@system1 test]# ls 1 2 3 4 5 6 7 a.tar.gz
關(guān)于如何進(jìn)行tar打包且排除某個(gè)文件就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,可以學(xué)到更多知識。如果覺得文章不錯(cuò),可以把它分享出去讓更多的人看到。
文章標(biāo)題:如何進(jìn)行tar打包且排除某個(gè)文件-創(chuàng)新互聯(lián)
文章起源:http://chinadenli.net/article18/cohhdp.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站制作、微信小程序、ChatGPT、品牌網(wǎng)站設(shè)計(jì)、搜索引擎優(yōu)化、外貿(mào)建站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容