溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

如何使用tar包提取某個文件到指定路徑

發(fā)布時間:2020-05-27 11:05:18 來源:億速云 閱讀:1031 作者:Leah 欄目:系統(tǒng)運維

如何使用tar包提取某個文件到指定路徑?針對這個問題,今天小編總結(jié)了這篇文章,希望能幫助更多想解決這個問題的朋友找到更加簡單易行的辦法。

tar tvf yourtarfile |grep fileyouwant,
tar xvf yourtarfile fileyouwant(copy上面的全路徑用絕對路徑)

tar.gz包

tar ztvf yourtargzfile |grep fileyouwant,

tar zxvf yourtarfile fileyouwant(copy上面的全路徑用絕對路徑)

思路就是先查出文件路徑,再解壓。但是上面的“全路徑用絕對路徑”是什么,經(jīng)過折騰才算明白。先看操作過程。

[root@fengzw test]# pwd
/root/test
[root@fengzw test]# ls
mariadb-10.4.12.tar.gz
[root@fengzw test]# tar -tzvf mariadb-10.4.12.tar.gz | grep CMakeLists.txt
.....
-rw-rw-r-- buildbot/buildbot    17932 2020-01-27 04:43 mariadb-10.4.12/CMakeLists.txt
......
[root@fengzw test]# tar -zxvf mariadb-10.4.12.tar.gz mariadb-10.4.12/CMakeLists.txt -C ../
mariadb-10.4.12/CMakeLists.txt
[root@fengzw test]# cd ..
[root@fengzw ~]# ls
anaconda-ks.cfg  CentOS-CR.repo  CentOS-Debuginfo.repo  CentOS-fasttrack.repo  CentOS-Sources.repo  CentOS-Vault.repo  test  tools
[root@fengzw ~]# ls test/
mariadb-10.4.12  mariadb-10.4.12.tar.gz
[root@fengzw ~]# ls test/mariadb-10.4.12
CMakeLists.txt

切換個目錄運行測試:

[root@fengzw ~]# ls test/
mariadb-10.4.12.tar.gz
[root@fengzw ~]# ls tools/testtar/
[root@fengzw ~]# tar -zxvf test/mariadb-10.4.12.tar.gz mariadb-10.4.12/CMakeLists.txt -C tools/testtar/
mariadb-10.4.12/CMakeLists.txt
[root@fengzw ~]# ls tools/testtar/
[root@fengzw ~]# ls test
mariadb-10.4.12.tar.gz
[root@fengzw ~]# ls
anaconda-ks.cfg  CentOS-CR.repo  CentOS-Debuginfo.repo  CentOS-fasttrack.repo  CentOS-Sources.repo  CentOS-Vault.repo  mariadb-10.4.12  test  tools
[root@fengzw ~]# ls mariadb-10.4.12/
CMakeLists.txt

以上就是使用tar包提取某個文件到指定路徑的詳細(xì)內(nèi)容了,看完之后是否有所收獲呢?如果想了解更多相關(guān)內(nèi)容,歡迎關(guān)注億速云行業(yè)資訊!

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI