Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use the tar package to extract a file to a specified path

2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

How do I use the tar package to extract a file to a specified path? In response to this problem, the editor summed up this article today, hoping to help more friends who want to solve this problem to find a more simple and feasible way.

Tar tvf yourtarfile | grep fileyouwant

Tar xvf yourtarfile fileyouwant (all paths above copy are absolute paths)

Tar.gz package

Tar ztvf yourtargzfile | grep fileyouwant

Tar zxvf yourtarfile fileyouwant (all paths above copy are absolute paths)

The idea is to find out the file path first, and then decompress it. But what is the "full path with absolute path" above can only be understood by twists and turns. Let's first look at the operation process.

[root@fengzw test] # pwd/root/test [root@fengzw test] # lsmariadb-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 ~] # lsanaconda-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.12CMakeLists.txt

Change to a directory to run the test:

[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 testmariadb-10.4.12.tar.gz [root@fengzw ~ ] # lsanaconda-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

The above is the use of tar package to extract the details of a file to the specified path, after reading it, do you have anything to gain? If you want to know more about it, you are welcome to follow the industry information!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report