免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
楼主: yinyuemi
打印 上一主题 下一主题

[学习共享] awk初学之常见问题 [复制链接]

论坛徽章:
2
射手座
日期:2014-10-10 15:59:4715-16赛季CBA联赛之上海
日期:2016-03-03 10:27:14
71 [报告]
发表于 2012-07-18 00:00 |只看该作者
本帖最后由 yinyuemi 于 2012-07-18 00:01 编辑

回复 69# guoweiqust
-path pattern
              File name matches shell pattern  pattern.   The  metacharacters  do  not
              treat `/' or `.' specially; so, for example,
                        find . -path "./sr*sc"
              will print an entry for a directory called `./src/misc' (if one exists).
              To ignore a whole directory tree, use -prune rather than checking  every
              file  in  the  tree.  For example, to skip the directory `src/emacs' and
              all files and directories under it, and print the  names  of  the  other
              files found, do something like this:
                        find . -path ./src/emacs -prune -o -print

              Note  that the pattern match test applies to the whole file name, starting
              from one of the start points named on the command  line.   It  would
              only  make sense to use an absolute path name here if the relevant start
              point is also an absolute path.  This means that this command will never
              match anything:
                        find bar -path /foo/bar/myfile -print
              Find  compares  the -path argument with the concatenation of a directory
              name and the base name of the file it's examining.  Since the concatenation
              will never end with a slash, -path arguments ending in a slash will
              match nothing (except perhaps a start point  specified  on  the  command
              line).   The predicate -path is also supported by HP-UX find and will be
              in a forthcoming version of the POSIX standard.

论坛徽章:
0
72 [报告]
发表于 2012-07-18 09:17 |只看该作者
回复 71# yinyuemi

这段话中所说的是不是这样的:
1>其中第一段话说明是man page中的,讲的是-prune的作用
2>第二段说明如果start point用的是绝对路径,则-path不能使用相对路径
  1. x900010-p0024@login1-565% find chinaunix -path chinaunix/awk_basic -prune -o -print
  2. chinaunix
  3. chinaunix/datafile
  4. chinaunix/repeat
复制代码
  1. x900010-p0024@login1-566% find chinaunix -path ./chinaunix/awk_basic -prune -o -print
  2. chinaunix
  3. chinaunix/datafile
  4. chinaunix/awk_basic
  5. chinaunix/awk_basic/grade.txt
  6. chinaunix/awk_basic/student_tot.awk
  7. chinaunix/awk_basic/temp
  8. chinaunix/awk_basic/strip
  9. chinaunix/awk_basic/grade_student.txt
  10. chinaunix/awk_basic/grade_student.awk
  11. chinaunix/repeat
复制代码
3>第三段说明检查连续路径时,-path的argument不能以slash结尾
  1. x900010-p0024@login1-567% find chinaunix -path chinaunix/awk_basic/ -prune -o -print
  2. chinaunix
  3. chinaunix/datafile
  4. chinaunix/awk_basic
  5. chinaunix/awk_basic/grade.txt
  6. chinaunix/awk_basic/student_tot.awk
  7. chinaunix/awk_basic/temp
  8. chinaunix/awk_basic/strip
  9. chinaunix/awk_basic/grade_student.txt
  10. chinaunix/awk_basic/grade_student.awk
  11. chinaunix/repeat
复制代码
是这样吗?
4>但是,我依然感觉不到和-o有什么关系,我把-o换成-a又得到不一样的结果
  1. x900010-p0024@login1-571% find chinaunix -path chinaunix/awk_basic -prune -o -print
  2. chinaunix
  3. chinaunix/datafile
  4. chinaunix/repeat
复制代码
换成-a
  1. x900010-p0024@login1-570% find chinaunix -path chinaunix/awk_basic -prune -a -print
  2. chinaunix/awk_basic
复制代码
求赐教。。。
   

论坛徽章:
2
射手座
日期:2014-10-10 15:59:4715-16赛季CBA联赛之上海
日期:2016-03-03 10:27:14
73 [报告]
发表于 2012-07-18 10:46 |只看该作者
回复 72# guoweiqust


    -a 和 -o 是逻辑判断符号,相当于 “&&” 和 “||”
   
-prune True; if the file is a directory, do not descend into it. If -depth is given, false;  no  effect.
              Because -delete implies -depth, you cannot usefully use -prune and -delete together.

   上面是-prune的使用描述,注意它的值用于为真,除非有-depth。
   另外,find 命令执行过程,可以理解为其后每个表达式逻辑判断“汇总”的结果
   

论坛徽章:
0
74 [报告]
发表于 2012-07-31 16:35 |只看该作者
太棒了,学习了

论坛徽章:
2
数据库技术版块每日发帖之星
日期:2015-08-03 06:20:00IT运维版块每日发帖之星
日期:2015-08-07 06:20:00
75 [报告]
发表于 2012-09-13 15:37 |只看该作者
谢谢分享 学习中

论坛徽章:
1
射手座
日期:2014-03-10 14:24:52
76 [报告]
发表于 2012-11-05 16:10 |只看该作者
又看了一遍还是有收获,很多东西需要温故知新。

论坛徽章:
0
77 [报告]
发表于 2013-01-12 19:50 |只看该作者
我也是非计算机专业的,向楼主学习!

论坛徽章:
0
78 [报告]
发表于 2013-03-12 10:10 |只看该作者
学习了。。。。

论坛徽章:
0
79 [报告]
发表于 2013-03-13 10:19 |只看该作者
收藏。。。。

论坛徽章:
1
黑曼巴
日期:2017-11-27 16:06:48
80 [报告]
发表于 2013-04-27 14:47 |只看该作者
膜拜了。这种帖子怎么让他沉下去呢。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP