Chinaunix首页 | 论坛 | 博客
  • 博客访问: 89765
  • 博文数量: 41
  • 博客积分: 1649
  • 博客等级: 上尉
  • 技术积分: 415
  • 用 户 组: 普通用户
  • 注册时间: 2005-07-20 17:02
文章分类

全部博文(41)

文章存档

2011年(4)

2010年(1)

2009年(14)

2008年(2)

2006年(6)

2005年(14)

我的朋友

分类:

2005-07-26 08:47:45

查找技巧,find及xargs的使用

Linux:       find /usr/sam -path "/usr/sam/dir1" -prune -o -print

Solaris:    find /usr/sam -name "/usr/sam/dir1" -prune -o -print                        or

               find /usr/sam -print -name "/usr/sam/dir1" -prune

find [path ..] [expression] 在路径列表的后面的是表达式
-path "/usr/sam" -prune -o -print 是 -path "/usr/sam" -a -prune -o -print 的简写表达式按顺序求值, -a 和 -o 都是短路求值,与 shell 的 && 和 || 类似如果 -path "/usr/sam" 为真,则求值 -prune , -prune 返回真,与逻辑表达式为真;否则不求值 -prune ,与逻辑表达式为假。 如果 -path "/usr/sam" -a -prune 为假,则求值 -print ,-print 返回真,或逻辑表达式为真;否则不求值 -print,或逻辑表达式为真

避开一些指定目录的查找时两个目录表示方法必须相同,否则不起作用要么都用绝对路径,要么都用相对路径
find . -path ./abc -prune -o -print 或 find /apps -path /apps/abc -prune -o -print
用下边的混用方式则不起作用 find . -path /apps/abc -prune -o -print


术语“改变时间(change time)”和“修改时间(modification time)”。

改变和修改之间的区别在于是改某个组件的标签还是更改它的内容。如果有人说chmod a-w myfile,那么这是一个改变;如果有人说echo foo >>myfile。则这是一个修改。改变是文件的索引节点发生了改变;修改是文本本身的内容发生了变化。[文件的修改时间也叫时间标志(timestamp).]
只要讨论改变时间和修改时间,就不可能不提到“访问时间(access time)”.访问时间是文件最后一次被读取的时间。因此阅读一个文件会更新它的访问时间,当它的改变时间并没有变化(有关文件的信息没有被改变),它的修改时间也同样如此(文件本身没有被改变)

mtime ls -l 最近修改文件内容的时间
atime ls -lu 最近访问文件的时间
ctime ls -li 最近文件有所改变的状态 ,如文件修改,属性属主 改变 ,节点 ,链接变化等 ,应该是不拘泥只是时间前后的改变

-c Uses time of last modification of the i-node (file created, mode changed, and so forth) for sorting (-t) or printing (-l or -n).
-u Uses time of last access instead of last modification for sorting (with the -t option) or printing (with the -l option).
-i For each file, prints the i-node number in the first column of the report.

-perm mode:文件许可正好符合mode
-perm +mode:文件许可部分符合mode
-perm -mode: 文件许可完全符合mode

阅读(890) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~