linux复制、压缩打包、解压缩等操作 您所在的位置:网站首页 linux常用命令拷贝文件夹到up linux复制、压缩打包、解压缩等操作

linux复制、压缩打包、解压缩等操作

2023-04-23 22:59| 来源: 网络整理| 查看: 265

1. 复制:cp命令,可复制一个文件夹下的所有文件和子目录、子文件,但是不包括本目录名,例如:不想包含目录名python3.7,想包含的是该目录下的所有子文件和子目录

cp -r /usr/local/python3.7/lib/python3.7/* /home/user_name/lib_words

2. 压缩 zip:同时将test001,test002中的所有文件压缩打包成test.zip,或者同时压缩当前目录下的所有文件、子目录、子文件到某个路径下的zip

zip -r test.zip test001 test002zip -r /home/user_name/lib_words.zip ./* #压缩当前目录的所有文件、子目录、子文件

3. 解压缩 unzip:将test.zip解压缩到某个目录下,例如目录/home/user_name/test

unzip test.zip -d /home/user_name/test

4. 建立文件夹:mkdir

mkdir lib_words

5. 显示当前目录下的文件:ls

ls ls -a

 6. 将文件/文件夹从zip压缩文件中删除

zip -d lib_words.zip numpy #删除numpy文件夹 zip -d lib_words.zip numpy* #删除以numpy开头的文件/文件夹 zip -d lib_words.zip xxx.py #删除xxx.py文件

7. 将文件添加到zip压缩文件

zip -m lib_words.zip ./xxx.py #将xxx.py添加到压缩文件

8. tar压缩,后缀是tar的,当然也可以是tar.gz,tar.bz2等格式,只是需要不同的参数

tar -cf doc_file.tar *.doc #将当前目录下的所有doc文件打包压缩成doc_file.tar,-c表示产生新的压缩文件,-f表示压缩文件名 tar -rf doc_file.tar *.ppt #将当前目录下的所有ppt文件追加到doc_file.tar压缩文件中,-r表示追加 tar -uf doc_file.tar xxx.doc #更新tar压缩文件中的xxx.doc文件,-u表示更新 tar -tf doc_file.tar #列出压缩文件中的文件名 tar -xf doc_file.tar #解压文件

 9. tar.gz,tar.bz2,tar.Z文件

同理: # tar.gz的压缩,加入-z tar -czf doc_file.tar.gz *.doc # tar.gz的解压 tar -xzf doc_file.tar.gz # tar.bz2的压缩与解压,加入-j tar -cjf doc_file.tar.bz2 *.doc tar -xjf doc_file.tar.bz2 # tar.Z的压缩与解压,加入-Z tar -cZf doc_file.tar.Z *.doc tar -xZf doc_file.tar.Z

10. -v 参数表示报告tar处理的文件信息

 

参考:

https://www.cnblogs.com/yves0923/p/10965021.html

# -----------------------------------------------------------------------------------------------

# 持续更新linux小命令



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有