20231117在ubuntu20.04下使用ZIP命令压缩文件夹

news2024/9/25 23:23:44

20231117在ubuntu20.04下使用ZIP命令压缩文件夹
2023/11/17 17:01


百度搜索:Ubuntu zip 压缩

https://blog.51cto.com/u_64214/7641253
Ubuntu压缩文件夹zip命令 原创
chenglei1208 2023-09-28 17:21:58博主文章分类:LINUX 小工具
文章标签命令行压缩包Ubuntu文章分类运维阅读数1554

一、安装zip命令
如果您的Ubuntu系统没有安装zip命令,可以使用以下命令进行安装:

sudo apt-get update
sudo apt-get install zip


输入密码并等待安装完成。

二、压缩单个文件夹
在命令行中,使用zip命令压缩单个文件夹非常简单。以下是基本的命令格式:

zip -r 压缩包名.zip 要压缩的文件夹路径

其中,-r参数表示递归压缩子目录。

例如,如果要将目录/home/user/documents压缩为documents.zip,可以使用以下命令:

zip -r documents.zip /home/user/documents

执行上述命令后,压缩包documents.zip将会生成在当前命令行所在目录下。

解压缩

解压目录

使用unzip命令时,可以指定解压目录。如果不指定解压目录,则默认解压到当前目录。例如,将压缩文件example.zip解压到/home/user/目录下,可以使用以下命令:

unzip example.zip -d /home/user/


三、压缩多个文件夹
如果要同时压缩多个文件夹,可以在命令行中依次指定要压缩的文件夹路径,并用空格进行分隔。例如,要同时压缩/home/user/documents和/home/user/pictures两个文件夹,可以使用以下命令:

zip -r archive.zip /home/user/documents /home/user/pictures

执行上述命令后,压缩包archive.zip将会生成在当前命令行所在目录下。

四、使用过滤器
有时候,在压缩文件夹时,您可能只需要压缩其中的部分文件或目录。Zip命令提供了一些过滤器选项,可以满足您的需求。

以下是几个常用的过滤器:

-x:排除指定的文件或目录。
-i:仅包括指定的文件或目录。
例如,要压缩目录/home/user/documents,但排除其中的/home/user/documents/cache目录,可以使用以下命令:

zip -r documents.zip /home/user/documents -x /home/user/documents/cache

执行上述命令后,压缩包documents.zip将会生成在当前命令行所在目录下,其中不包含/home/user/documents/cache目录。

五、总结
通过本篇文章,您已经学会了在Ubuntu系统中使用zip命令压缩文件夹的基本操作。如果您想了解更多zip命令的使用方法和选项,请查阅zip命令的帮助文档。


rootroot@rootroot-HP-ZHAN-66-Pro-A-14-G3:~/C101$ 
rootroot@rootroot-HP-ZHAN-66-Pro-A-14-G3:~/C101$ ll
total 1505032
drwxrwxr-x  3 rootroot rootroot      4096 11月 17 13:59 ./
drwxr-xr-x 29 rootroot rootroot      4096 11月 17 13:54 ../
-rw-rw-r--  1 rootroot rootroot 770564405 11月 17 13:58 1356.tar.gz
-rw-rw-r--  1 rootroot rootroot 770560989 11月 17 14:00 1359.tar.gz
drwxrwxr-x 26 rootroot rootroot      4096 11月 17 13:56 fastiot/
rootroot@rootroot-HP-ZHAN-66-Pro-A-14-G3:~/C101$ 
rootroot@rootroot-HP-ZHAN-66-Pro-A-14-G3:~/C101$ 
rootroot@rootroot-HP-ZHAN-66-Pro-A-14-G3:~/C101$ zip fastiot_20231117_1402.zip fastiot/

rootroot@rootroot-HP-ZHAN-66-Pro-A-14-G3:~/C101$ 
rootroot@rootroot-HP-ZHAN-66-Pro-A-14-G3:~/C101$ ll
total 1505032
drwxrwxr-x  3 rootroot rootroot      4096 11月 17 13:59 ./
drwxr-xr-x 29 rootroot rootroot      4096 11月 17 13:54 ../
-rw-rw-r--  1 rootroot rootroot 770564405 11月 17 13:58 1356.tar.gz
-rw-rw-r--  1 rootroot rootroot 770560989 11月 17 14:00 1359.tar.gz
drwxrwxr-x 26 rootroot rootroot      4096 11月 17 13:56 fastiot/
rootroot@rootroot-HP-ZHAN-66-Pro-A-14-G3:~/C101$ 
rootroot@rootroot-HP-ZHAN-66-Pro-A-14-G3:~/C101$ 
rootroot@rootroot-HP-ZHAN-66-Pro-A-14-G3:~/C101$ zip fastiot_20231117_1402.zip fastiot/
  adding: fastiot/ (stored 0%)
rootroot@rootroot-HP-ZHAN-66-Pro-A-14-G3:~/C101$ 
rootroot@rootroot-HP-ZHAN-66-Pro-A-14-G3:~/C101$ zip -r fastiot_20231117_1403.zip fastiot/


  adding: fastiot/ConfigManagerNode/inc/Config_key.h (deflated 67%)
  adding: fastiot/ConfigManagerNode/inc/capabilityManager.h (deflated 53%)
  adding: fastiot/ConfigManagerNode/src/ (stored 0%)
  adding: fastiot/ConfigManagerNode/src/configManager.cpp (deflated 88%)
  adding: fastiot/ConfigManagerNode/src/Makefile (deflated 52%)
  adding: fastiot/ConfigManagerNode/src/capabilityManager.cpp (deflated 74%)
  adding: fastiot/ConfigManagerNode/src/Config_get.cpp (deflated 77%)
  adding: fastiot/DataEngine/ (stored 0%)
  adding: fastiot/DataEngine/inc/ (stored 0%)
  adding: fastiot/DataEngine/inc/TalkCollector.h (deflated 45%)
  adding: fastiot/DataEngine/inc/BatteryCollector.h (deflated 43%)
  adding: fastiot/DataEngine/inc/MonitorCollector.h (deflated 45%)
  adding: fastiot/DataEngine/inc/Upgrade_Processor.h (deflated 43%)
  adding: fastiot/DataEngine/inc/Cloud_Processor.h (deflated 47%)
  adding: fastiot/DataEngine/inc/SDLog_Processor.h (deflated 43%)
  adding: fastiot/DataEngine/inc/Rtsp_Processor.h (deflated 45%)
  adding: fastiot/DataEngine/inc/S3Client_Processor.h (deflated 48%)
  adding: fastiot/DataEngine/inc/IOCtrl_Collector.h (deflated 45%)
  adding: fastiot/DataEngine/inc/Cgi_Processor.h (deflated 38%)
  adding: fastiot/DataEngine/inc/FactoryCollector.h (deflated 46%)
  adding: fastiot/DataEngine/inc/Config_Collector.h (deflated 43%)
  adding: fastiot/DataEngine/inc/VideoProducer.h (deflated 36%)
  adding: fastiot/DataEngine/inc/list.h (deflated 80%)
  adding: fastiot/DataEngine/inc/SDCardRecord_Processor.h (deflated 48%)
  adding: fastiot/DataEngine/inc/AudioProducer.h (deflated 37%)
  adding: fastiot/DataEngine/inc/ReverVideo_Collector.h (deflated 47%)
  adding: fastiot/DataEngine/inc/MsgCore.h (deflated 67%)
  adding: fastiot/DataEngine/src/ (stored 0%)
  adding: fastiot/DataEngine/src/MsgCoreControlServer.cpp (deflated 71%)
  adding: fastiot/DataEngine/src/Config_Collector.cpp (deflated 81%)
  adding: fastiot/DataEngine/src/MsgCoreControlClient.cpp (deflated 74%)
  adding: fastiot/DataEngine/src/AudioProducer.cpp (deflated 74%)
  adding: fastiot/DataEngine/src/ReverVideo_Collector.cpp (deflated 77%)
  adding: fastiot/DataEngine/src/SDCardRecord_Processor.cpp (deflated 79%)
  adding: fastiot/DataEngine/src/SDLog_Processor.cpp (deflated 72%)
  adding: fastiot/DataEngine/src/Upgrade_Processor.cpp (deflated 71%)
  adding: fastiot/DataEngine/src/Cloud_Processor.cpp (deflated 73%)
  adding: fastiot/DataEngine/src/Makefile (deflated 61%)
  adding: fastiot/DataEngine/src/BatteryCollector.cpp (deflated 73%)
  adding: fastiot/DataEngine/src/MonitorCollector.cpp (deflated 75%)
  adding: fastiot/DataEngine/src/FactoryCollector.cpp (deflated 76%)
  adding: fastiot/DataEngine/src/Cgi_Processor.cpp (deflated 71%)
  adding: fastiot/DataEngine/src/S3Client_Processor.cpp (deflated 72%)
  adding: fastiot/DataEngine/src/VideoProducer.cpp (deflated 77%)
  adding: fastiot/DataEngine/src/MsgCoreServ.cpp (deflated 80%)
  adding: fastiot/DataEngine/src/IOCtrl_Collector.cpp (deflated 74%)
  adding: fastiot/DataEngine/src/TalkCollector.cpp (deflated 77%)
  adding: fastiot/DataEngine/src/Rtsp_Processor.cpp (deflated 70%)
rootroot@rootroot-HP-ZHAN-66-Pro-A-14-G3:~/C101$ 
rootroot@rootroot-HP-ZHAN-66-Pro-A-14-G3:~/C101$ ll
total 2292296
drwxrwxr-x  3 rootroot rootroot      4096 11月 17 14:04 ./
drwxr-xr-x 29 rootroot rootroot      4096 11月 17 13:54 ../
-rw-rw-r--  1 rootroot rootroot 770564405 11月 17 13:58 1356.tar.gz
-rw-rw-r--  1 rootroot rootroot 770560989 11月 17 14:00 1359.tar.gz
drwxrwxr-x 26 rootroot rootroot      4096 11月 17 13:56 fastiot/
-rw-rw-r--  1 rootroot rootroot       166 11月 17 14:02 fastiot_20231117_1402.zip
-rw-rw-r--  1 rootroot rootroot 806147076 11月 17 14:04 fastiot_20231117_1403.zip
rootroot@rootroot-HP-ZHAN-66-Pro-A-14-G3:~/C101$ 
rootroot@rootroot-HP-ZHAN-66-Pro-A-14-G3:~/C101$ 


 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1223577.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

打不开github网页解决方法

问题: 1、composer更新包总是失败 2、github打不开,访问不了 解决方法:下载一个Watt Toolkit工具,勾选上,一键加速就可以打开了。 下载步骤: 1、打开网址: Watt Toolkit 2、点击【下载wind…

Python (十一) 迭代器与生成器

迭代器 迭代器是访问集合元素的一种方式,可以记住遍历的位置的对象 迭代器有两个基本的方法:iter() 和 next() 字符串,列表或元组对象都可用于创建迭代器 字符串迭代 str1 Python str_iter iter(str1) print(next(str_iter)) print(next(st…

原型网络Prototypical Network的python代码逐行解释,新手小白也可学会!!-----系列2

文章目录 一、原始代码二、每一行代码的详细解释 一、原始代码 labels_trainData ,labels_testData load_data() wide labels_trainData[0][0].shape[0] length labels_trainData[0][0].shape[1] for label in labels_trainData.keys():labels_trainData[label] np.reshap…

FastJsonAPI

maven项目 pom.xml <dependencies><dependency><groupId>com.alibaba</groupId><artifactId>fastjson</artifactId><version>2.0.26</version></dependency><dependency><groupId>junit</groupId>&l…

vmware17 虚拟机拷贝、备份、复制使用

可以在虚拟机运行的情况下进行拷贝 查看新安装的虚拟机位置 跳转到上一级目录 复制虚拟机 复制虚拟机整个目录 删除lck文件&#xff0c;不然开机的时候会报错 用vmware 打开新复制的虚拟机 lck文件全部删除 点击开机 开机成功

软磁交流测试仪系统磁参量指标

1. 主要应用 2. 软磁交流测试仪磁参量指标 被测参数 最佳测量不确定度 ( k 2 ) 1 kHz 最佳测量重复性 主要动态磁特性参数 Ps 2.0% 1.0% μa 3.0% 1.0% Bm 1.0% 0.5% Hm 1.0% 0.5% δ 5.0% 1.5% 其他磁特性参数供参考 Br 2.0% 1.0% Hc 3.0% 1.0% μ…

振南技术干货集:比萨斜塔要倒了,倾斜传感器快来!(6)

注解目录 1、倾斜传感器的那些基础干货 1.1 典型应用场景 &#xff08;危楼、边坡、古建筑都是对倾斜敏感的。&#xff09; 1.2 倾斜传感器的原理 1.2.1 滚珠式倾斜开关 1.2.2 加速度式倾斜传感器 1)直接输出倾角 2)加速度计算倾角 3)倾角精度的提高 &#xff08;如果…

微积分在神经网络中的本质

calculus 在一个神经网络中我们通常将每一层的输出结果表示为&#xff1a; a [ l ] a^{[l]} a[l] 为了方便记录&#xff0c;将神经网络第一层记为&#xff1a; [ 1 ] [1] [1] 对应的计算记录为为&#xff1a; a [ l ] &#xff1a; 第 l 层 a [ j ] &#xff1a; 第 j 个神经…

How to import dgl-cu113 如何导入 dgl-cu113

参考这个 从How to import dgl-cu113 如何导入 dgl-cu113https://discuss.dgl.ai/t/how-to-import-dgl-cu113/3381https://discuss.dgl.ai/t/how-to-import-dgl-cu113/3381

vscode 推送本地新项目到gitee

一、gitee新建仓库 1、填好相关信息后点击创建 2、创建完成后复制 https&#xff0c;稍后要将本地项目与此关联 3、选择添加远程存储库 4、输入仓库地址&#xff0c;选择从URL添加远程存储仓库 5、输入仓库名称&#xff0c;确保仓库名一致

Redis:新的3种数据类型Bitmaps、HyperLoglog、Geographic

目录 Bitmaps简介常用命令bitmaps与set比较 HyperLoglog简介命令 Geographic简介命令 Bitmaps 简介 位操作字符串。 现代计算机使用二进制&#xff08;位&#xff09;作为信息的基本单位&#xff0c;1个字节等于8位&#xff0c;例如“abc”字符串是有3个字节组成&#xff0c…

开发一款回合制游戏,需要注意什么?

随着游戏行业的蓬勃发展&#xff0c;回合制游戏因其深度的策略性和令人着迷的游戏机制而受到玩家们的热烈欢迎。如果你计划投身回合制游戏的开发领域&#xff0c;本文将为你提供一份详细的指南&#xff0c;从游戏设计到发布&#xff0c;助你成功打造一款引人入胜的游戏。 1. 游…

记一次用jlink调试正常,不进入调试就不能运行的情况

一、概述 我开机会闪烁所有指示灯&#xff0c;但是重新上电时&#xff0c;指示灯并没有闪烁&#xff0c;就像"卡死"了一样。 使用jlink的swd接口进行调试&#xff0c;需要多点几次运行才能跳转到main函数里面。 调试模式第一次点击运行&#xff0c;暂停查看函数堆栈…

开源与闭源:创新与安全的平衡

目录 一、开源和闭源的优劣势比较 一、开源软件的优劣势 优势 劣势 二、闭源软件的优劣势 优势 劣势 二、开源和闭源对大模型技术发展的影响 一、机器学习领域 二、自然语言处理领域 三、数据共享、算法创新与业务拓展的差异 三、开源与闭源的商业模式比较 一、盈…

【项目管理】PMO技能树21项参照

导读&#xff1a;PMO技能树让你能够有全局视野&#xff0c;让你对照着检查自己的能力是否掌握。技能树提供了构建个人知识体系参照和地图导航&#xff0c;不至于迷失方向。 目录 1、PMO层次概览 2、技能树 2.1 项目管理流程 2.2 项目组合管理 2.3 风险管理 2.4 项目资源管…

Python数据分析实战① Python实现数据可视化

文章目录 一、数据可视化介绍二、matplotlib和pandas画图1.matplotlib简介和简单使用2.matplotlib常见作图类型3.使用pandas画图4.pandas中绘图与matplotlib结合使用 三、订单数据分析展示四、Titanic灾难数据分析显示 一、数据可视化介绍 数据可视化是指将数据放在可视环境中…

爱拖延怎么办?如何改变拖延症?

拖延症是我们日常生活中多见的问题&#xff0c;也是不怎么受重视的问题&#xff0c;大多数人都会认为拖延不是什么大问题&#xff0c;办事拖拉怎么也不可能和心理疾病扯上关系。这里小猫测试网分不同情况来讨论。 偶尔的拖延没什么关系&#xff0c;建议忘掉这种偶然性拖延&…

互联网医院牌照|智慧医疗离不开牌照办理

互联网医院牌照是由卫生健康行政部门颁布的&#xff0c;所有材料审核通过后&#xff0c;相关部门授予《医疗机构执业许可证》&#xff0c;取得牌照后才有开展互联网诊疗活动的资质&#xff0c;但开展线上问诊也需要向发证机关提出申请&#xff0c;下面小编就给大家讲解下互联网…