tar命令解压缩 去掉压缩包中顶级目录

您所在的位置:网站首页 为什么tar解压不出来文件 tar命令解压缩 去掉压缩包中顶级目录

tar命令解压缩 去掉压缩包中顶级目录

2023-08-05 23:38| 来源: 网络整理| 查看: 265

tar命令解压缩,去掉顶级目录

可以理解为,将压缩包内文件解压出来后,散落一地的感觉 在tar 命令后加上:

--strip-components 1 例如,解压tomcat

正常情况,解压后会出现apache-tomcat-9.0.37文件夹:

[root@localhost ~]# tar -zxvf apache-tomcat-9.0.37.tar.gz -C ./tomcat [root@localhost ~]# ls tomcat/ apache-tomcat-9.0.37 [root@localhost ~]# ls tomcat/apache-tomcat-9.0.37/ bin BUILDING.txt conf CONTRIBUTING.md lib LICENSE logs NOTICE README.md RELEASE-NOTES RUNNING.txt temp webapps work [root@localhost ~]#

去掉顶级目录后为:

[root@localhost ~]# tar -zxvf apache-tomcat-9.0.37.tar.gz -C ./tomcat --strip-components 1 [root@localhost ~]# ls tomcat/ bin BUILDING.txt conf CONTRIBUTING.md lib LICENSE logs NOTICE README.md RELEASE-NOTES RUNNING.txt temp webapps work

可以看到,解压后的目录结构中,没有出现apache-tomcat-9.0.37文件夹



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3