9、文件查找与压缩面试题
试题
自己做
1、find -name 111.txt
2、find /data/files -type f -mtime +7 -size +10M -exec rm {} \;
3、find /test -user jorm -name "abc*"
4、find -type f -ctime +30 -name "*.log" -size +1G -exec mv {} /tmp \;
5、tar -cf /data/etc_bak.tar /etc
6、find /data/ -type d -empty -exec mv {} /tmp \;
7、find /home -type f -size +1G -exec rm {} \;
8、有以下几个:
-
compress压缩(-d解压缩),uncompress解压
扫描二维码关注公众号,回复: 6942473 查看本文章[root@centos7 tmp]# compress man.txt #压缩 [root@centos7 tmp]# ls man.txt.Z [root@centos7 tmp]# uncompress man.txt.Z #解压 [root@centos7 tmp]# ls man.txt [root@centos7 tmp]# compress man.txt #压缩 [root@centos7 tmp]# compress -d man.txt.Z #解压 [root@centos7 tmp]# ls man.txt [root@centos7 tmp]# man man | gzip > man.gz
-
gzip压缩(-d解压)gunzip解压
[root@centos7 tmp]# gzip man.txt #压缩 [root@centos7 tmp]# ls man.txt.gz [root@centos7 tmp]# gunzip man.txt.gz #解压 [root@centos7 tmp]# ls man.txt [root@centos7 tmp]# gzip man.txt #压缩 [root@centos7 tmp]# gzip -d man.txt.gz #解压 [root@centos7 tmp]# ls man.txt
-
xz压缩,unxz解压
-
tar
[root@centos7 tmp]# tar cf /data/etc.tar /etc/ #压缩 [root@centos7 tmp]# tar xf /data/etc.tar -C . #解压 [root@centos7 tmp]# ls etc man.gz # 压缩参数 # -z表示gzip # -j表示bzip2 # -J表示xz
-
zip -r /etc(压缩etc目录) unzip etc.zip(解压)
- zcat 不显式解压缩的情况下查看文件
9、ls /etc/*/ -d find /etc -type d
10、find /usr/local/web -type f -size +100M -exec mv {} /tmp/ \;
11、tar xf etc.tar.gz
zip
12、gzip tar czf test.tar.gz test
13、ldd
14、tar
15、sed -r '1,20s/aaa/AAA/' -e '1,20s/bbb/BBB/g' test.txt'
16、d
17、A
18、bd
18题问题:
xz压缩的文件无法tar解压
tar cJf创建的压缩包可以tar xf解压