3.2 6.5-6.7听课笔记

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了3.2 6.5-6.7听课笔记相关的知识,希望对你有一定的参考价值。

*Zip压缩工具

[[email protected] ~]# ls
1.txt 2.txt anaconda-ks.cfg d6z
[[email protected] ~]# du -sh 1.txt
1.6M 1.txt
[[email protected] ~]# zip 1.txt.zip 1.txt 将1.txt压缩
adding: 1.txt (deflated 83%)
[[email protected] ~]# du -sh 1.txt.zip 压缩后文件大小
272K 1.txt.zip
[[email protected] ~]# ls 压缩完成后原来的文件不会被删除
1.txt 1.txt.zip 2.txt anaconda-ks.cfg d6z
[[email protected] ~]# zip -r d6z.zip 2.txt d6z 压缩目录要加-r
adding: 2.txt (stored 0%)
adding: d6z/ (stored 0%)
adding: d6z/33.txt (stored 0%)
adding: d6z/22.txt.xz (deflated 1%)
adding: d6z/222.txt (deflated 71%)
adding: d6z/111.txt (deflated 79%)
adding: d6z/11.txt (deflated 79%)
adding: d6z/hyc/ (stored 0%)
adding: d6z/hyc/.bashlogout (stored 0%)
adding: d6z/hyc/.bashprofile (deflated 21%)
adding: d6z/hyc/.bashrc (deflated 23%)
adding: d6z/hyc/1.txt (deflated 73%)
adding: d6z/hyc/2.txt (deflated 73%)
adding: d6z/hyc/2/ (stored 0%)
adding: d6z/hyc/2/11.txt (deflated 79%)
[[email protected] ~]# du -sh d6z.zip
4.0K d6z.zip
[[email protected] ~]# unzip d6z.zip 解压压缩包
Archive: d6z.zip
replace 2.txt? [y]es, [n]o, [A]ll, [N]one, [r]ename: y
extracting: 2.txt
creating: d6z/
extracting: d6z/33.txt
inflating: d6z/22.txt.xz
inflating: d6z/222.txt
inflating: d6z/111.txt
inflating: d6z/11.txt
creating: d6z/hyc/
extracting: d6z/hyc/.bashlogout
inflating: d6z/hyc/.bashprofile
inflating: d6z/hyc/.bashrc
inflating: d6z/hyc/1.txt
inflating: d6z/hyc/2.txt
creating: d6z/hyc/2/
inflating: d6z/hyc/2/11.txt
[[email protected] ~]# unzip 1.txt.zip -d ./test 指定解压路径
Archive: 1.txt.zip
inflating: ./test/1.txt
[[email protected] ~]# unzip 1.txt.zip -d ./test/aa.txt 无法指定解压后的文件名,文件名固定
Archive: 1.txt.zip
inflating: ./test/aa.txt/1.txt

zip压缩包无法直接查看内容

[[email protected] ~]# unzip -l 1.txt.zip 查看压缩包的文件列表
Archive: 1.txt.zip
Length Date Time Name


1667480 03-03-2018 17:28 1.txt


1667480 1 file

Tar打包

1Mbyte=8Mbit
100M带宽理论传递速率为12.5Mbyte
百兆网卡是指100Mbit/s,跑满为12.5Mbyte/s
文件过多,不能一次传递所有文件,为了提高传输效率,可以先将所有文件、目录打成一个包
每个Inode的块为4k,若每个文件均不足4K,打包后原来每个块未用的部分会被填满,文件大小之和变小(打包可能减小文件大小)

[[email protected] ~]# tar -cvf d6z.tar d6z/ c创建tar包,v可视化打包过程,f指定tar包名字
d6z/
d6z/33.txt
d6z/22.txt.xz
d6z/222.txt
d6z/111.txt
d6z/11.txt
d6z/hyc/
d6z/hyc/.bashlogout
d6z/hyc/.bashprofile
d6z/hyc/.bashrc
d6z/hyc/1.txt
d6z/hyc/2.txt
d6z/hyc/2/
d6z/hyc/2/11.txt
[[email protected] ~]# tar -cf d6z.tar d6z/ 覆盖原来的tar包,无任何提示
[[email protected] ~]#
[[email protected] ~]# tar -xvf d6z.tar 解包,解包产生的文件会自动覆盖原来相同的文件,不提示
d6z/
d6z/33.txt
d6z/22.txt.xz
d6z/222.txt
d6z/111.txt
d6z/11.txt
d6z/hyc/
d6z/hyc/.bashlogout
d6z/hyc/.bashprofile
d6z/hyc/.bashrc
d6z/hyc/1.txt
d6z/hyc/2.txt
d6z/hyc/2/
d6z/hyc/2/11.txt
[[email protected] ~]# tar -cvf 1.txt.tar 1.txt d6z.tar 1.txt.zip 打包文件、包、压缩包
1.txt
d6z.tar
1.txt.zip
[[email protected] ~]#
[[email protected] ~]# tar -cvf 1.txt.tar 1.txt.tar 1.txt 问题
tar: 1.txt.tar: file is the archive; not dumped
1.txt
[[email protected] ~]#
[[email protected] ~]# tar -tf 1.txt.tar 查看打包的列表(1.txt.tar未打包)

  1. txt
  2. [[email protected] ~]# tar -cvf --exclude 1.txt d6z.tar 2.txt d6z
  3. 1.txt
  4. d6z.tar
  5. 2.txt
  6. d6z/
  7. d6z/hyc/
  8. d6z/hyc/2/
  9. d6z/hyc/2/11.txt
  10. d6z/hyc/.bashlogout
  11. d6z/hyc/.bashprofile
  12. d6z/hyc/.bashrc
  13. d6z/hyc/1.txt
  14. d6z/hyc/2.txt
  15. d6z/33.txt
  16. d6z/22.txt.xz
  17. d6z/222.txt
  18. d6z/111.txt
  19. d6z/11.txt
    [[email protected] ~]# tar -cvf 11.txt.tar --exclude 11.txt 1.txt.zip d6z 指定哪些文件不被打包,写在指定的包名后面,目标包名一定要和-f参数连在一起
    1.txt.zip
    d6z/
    d6z/hyc/
    d6z/hyc/2/
    d6z/hyc/.bashlogout
    d6z/hyc/.bashprofile
    d6z/hyc/.bashrc
    d6z/hyc/1.txt
    d6z/hyc/2.txt
    d6z/33.txt
    d6z/22.txt.xz
    d6z/222.txt
    d6z/111.txt
    [[email protected] ~]# tar -tf 11.txt.tar
    1.txt.zip
    d6z/
    d6z/hyc/
    d6z/hyc/2/
    d6z/hyc/.bashlogout
    d6z/hyc/.bashprofile
    d6z/hyc/.bashrc
    d6z/hyc/1.txt
    d6z/hyc/2.txt
    d6z/33.txt
    d6z/22.txt.xz
    d6z/222.txt
    d6z/111.txt
    [[email protected] ~]#
    [[email protected] ~]# tar -cf 11.txt.tar --exclude 11.txt --exclude 111.txt 1.txt.zip d6z 每增加一个排除项都要重写—exclude

打包并压缩

[[email protected] d6z]# tar czvf 11.tar.gz 111.txt 11.txt 222.txt tar打包,gzip压缩
111.txt
11.txt
222.txt
[[email protected] d6z]# du -sh
48K .
[[email protected] d6z]# du -sh 11.txt 111.txt 222.txt
4.0K 11.txt
4.0K 111.txt
4.0K 222.txt
[[email protected] d6z]# du -sh 11.tar.gz
4.0K 11.tar.gz
[[email protected] d6z]# tar cjvf 11.tar.bz2 111.txt 11.txt 222.txt tar打包,bzip2压缩
111.txt
11.txt
222.txt
[[email protected] d6z]#
[[email protected] d6z]# tar cJvf 11.tar.xz 111.txt 11.txt 222.txt tar打包,xz压缩
111.txt
11.txt
222.txt
压缩越狠,耗时越久
gzip为z,j为bzip2,J为xz
[[email protected] d6z]# tar xJvf 11.tar.xz 解包(c换成x)
111.txt
11.txt**
222.txt
[[email protected] d6z]# tar -tf 11.tar.bz2
列出压缩包的文件
111.txt
11.txt
222.txt
[[email protected] d6z]# tar -cvf 1.tar 11.txt 222.txt
11.txt
222.txt
[[email protected] d6z]# tar -tf 1.tar
列出被打包的文件*
11.txt
222.txt
[[email protected] d6z]#

以上是关于3.2 6.5-6.7听课笔记的主要内容,如果未能解决你的问题,请参考以下文章

python 听课笔记- 序(鸡汤)

APIO2017听课笔记关键词

听课笔记

Daily dictation 听课笔记

Struts+Hibernate 听课笔记

3.12 听课笔记