linux/unix shell的find用法小练
来源:互联网 发布:泰拉瑞亚存档导入软件 编辑:程序博客网 时间:2024/05/17 03:12
好久之前的笔记了,搬出来和大家共享:
参数解释:
find用来查询某个目录下的文件几种常用的参数如下
-path 后面跟着要查询的路径
-prune 表示不再指定目录下查询,如果同时使用-depth,那么-prune命令将会被忽略
-name 要查询的文件名,可以使用正则表达式来查询
-mtime 查询近n天更改过的文件+表示大于n,-n表示n天以内
-另外还有-atime和-ctime用法类似
-newer file1 ! -newer file2 表示查询比file1新,比file2旧的文件
-exec 表示对查询出来的文件进行某些命令操作,如 -exec ls -l {} \;
-type 要查询的文件类型
! -type d 表示除了类型为目录的
-size 指定大小的文件+10c或-10c:大于10个字节的,或者小于10个字节的
演示:
[oracle@localhost testDir]$ cat find.sh echo "prune:" >> find.outfind . -path "./folder" -prune -o -name "file*" >> find.outecho "-name:" >> find.outfind . -name "[a-z][a-z]*" >> find.outecho "-mtime: +3" >> find.outfind . -mtime +3 >> find.outecho "-mtime: -3" >> find.outfind . -mtime -3 >> find.outecho "find newer then 1 and older then 2 files:">> find.outfind . -newer "test1.sh" ! -newer "test2.sh" -exec ls -l {} \; >> find.outecho "-type:" >> find.outfind . -type d >> find.outecho "except type:" >> find.outfind . ! -type d >> find.outecho "-size +10c :" >> find.outfind . -size +10c >> find.outecho "-size -10c :" >> find.outfind . -size -10c >> find.out
输出结果:
[oracle@localhost testDir]$ cat find.out prune:./folder-name:./blank_file./find.sh./shelltest.sh./folder./folder/file1./test1.log./test1.sh./test2.sh./main.sh./find.out-mtime: +3./find.sh./shelltest.sh./folder./folder/file1./test1.sh./test2.sh./main.sh-mtime: -3../blank_file./test1.log./find.outfind newer then 1 and older then 2 files:-rwxr-xr-x 1 oracle oinstall 100 Nov 10 23:08 ./test2.sh-rwxr-xr-x 1 oracle oinstall 26 Nov 10 22:30 ./main.sh-type:../folderexcept type:./blank_file./find.sh./shelltest.sh./folder/file1./test1.log./test1.sh./test2.sh./main.sh./find.out-size +10c :../blank_file./find.sh./shelltest.sh./folder./test1.log./test1.sh./test2.sh./main.sh./find.out-size -10c :./folder/file1
- linux/unix shell的find用法小练
- [shell]find的用法
- Unix/Linux 的 shell
- shell find 命令的用法
- Unix Shell find/xargs
- [linux.admin.shell] find命令常用法
- [Shell]: Linux命令find命令用法总结
- linux shell find 常用用法总结
- linux find的用法
- linux find的用法
- linux find的用法
- Linux find的用法
- Unix中find用法
- UNIX/linux的find命令细节
- Shell之 find -exec -ok 的用法
- Shell 命令 find 的常见用法
- linux shell ${ }的用法
- linux shell ${ }的用法
- Struts2文件上传(二)-文件上传拦截器
- 我的初梦《梦幻重游》开发记录三
- rt-thread的IPC机制之互斥锁源码分析
- 删除文件夹里所有的.svn文件
- Ubuntu 12.04安装虚拟工具VMware Tools
- linux/unix shell的find用法小练
- 西电ACM2013年2月月赛--XDUOJ
- hdu 2060 snooker
- JQuery 插件 参考网站
- FreeBSD 9.1内核文件编译分析
- epoll和select区别
- 分布式持久化消息队列memcacheq的安装部署
- select,epoll,poll比较
- JNI如何调用Java函数