linux归档、查找并处理文件案例

tech2022-08-11  142

案例1:创建一个备份包

使用 tar 工具完成以下备份任务: – 创建一个名为 /root/backup.tar.bz2 的归档文件 – 其中包含 /usr/local 目录中的内容 – tar 归档必须使用 bzip2 进行压缩 ]# tar -jcf /root/backup.tar.bz2 /usr/local/

tar: 从成员名中删除开头的“/”

]# ls /root/

]# tar -tf /root/backup.tar.bz2 #查看tar包内容

案例2:查找并处理文件

1.利用find查找所有用户 student 拥有的必须是文件,把它们拷贝到 /root/findfiles/ 文件夹中 ]# useradd student ]# mkdir /root/findfiles ]# find / -user student -type f

]# find / -user student -type f -exec cp {} /root/findfiles/ ;

]# ls -A /root/findfiles/

最新回复(0)