find文件,tar打包和打包压缩
[root@localhost ~]#?find . -name "*.txt*" -name "*test*" -type f |xargs tar -cvf?test.tar.gz?? ? ??//找到當前目錄文件名包含“.txt”和“test”的文件,并打包成test.tar.gz
./test.txt.abc
./test.txt.bak
[root@localhost ~]# ll
總用量 88
-rw-------. 1 root root?? 912? 3月 19 09:47 anaconda-ks.cfg
-rw-r--r--. 1 root root 15832? 3月? 6 10:48 install.log
-rw-r--r--. 1 root root? 4538? 3月? 6 10:47 install.log.syslog
-rw-r--r--. 1 root root 30720? 3月 19 11:39 test.tar.gz
drwxr-xr-x. 2 root root? 4096? 3月 19 11:23 test.txt
-rw-r--r--. 1 root root 10240? 3月 19 11:36 test.txt.abc
-rw-r--r--. 1 root root 10240? 3月 19 11:36 test.txt.bak
[root@localhost ~]#?find . -name "*.txt*" -name "*test*" -type f |xargs tar -zcvf?studyA.tar.gz ? ???//找到當前目錄文件名包含“.txt”和“test”的文件,并打包壓縮成studyA.tar.gz
./test.txt.abc
./test.txt.bak
[root@localhost ~]# ll
總用量 92
-rw-------. 1 root root?? 912? 3月 19 09:47 anaconda-ks.cfg
-rw-r--r--. 1 root root 15832? 3月? 6 10:48 install.log
-rw-r--r--. 1 root root? 4538? 3月? 6 10:47 install.log.syslog
-rw-r--r--. 1 root root?? 158? 3月 19 11:53 studyA.tar.gz
-rw-r--r--. 1 root root 30720? 3月 19 11:39 test.tar.gz
drwxr-xr-x. 2 root root? 4096? 3月 19 11:23 test.txt
-rw-r--r--. 1 root root 10240? 3月 19 11:36 test.txt.abc
-rw-r--r--. 1 root root 10240? 3月 19 11:36 test.txt.bak
[root@localhost ~]#?
轉載于:https://blog.51cto.com/kongzi68/1622168
總結
以上是生活随笔為你收集整理的find文件,tar打包和打包压缩的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 关于js中window.location
- 下一篇: 信号量(一) 基础知识