免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
12下一页
最近访问板块 发新帖
查看: 3929 | 回复: 17
打印 上一主题 下一主题

find . -name "*.htm"|xargs -i grep -l "ffmail" {}|more [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-03-16 14:33 |只看该作者 |倒序浏览
怎么在bsd下这个xargs -i就莫发用了?
我想查找某部分文件内容中是否喊有某个字符,并且打印出这些文件名
现在bsd下就不行,linux下可以。

论坛徽章:
0
2 [报告]
发表于 2007-03-16 14:39 |只看该作者
J replstr
             If this option is specified, xargs will use the data read from
             standard input to replace the first occurrence of replstr instead
             of appending that data after all other arguments.        This option
             will not affect how many arguments will be read from input (-n),
             or the size of the command(s) xargs will generate (-s).  The
             option just moves where those arguments will be placed in the
             command(s) that are executed.  The replstr must show up as a dis-
             tinct argument to xargs.  It will not be recognized if, for
             instance, it is in the middle of a quoted string.        Furthermore,
             only the first occurrence of the replstr will be replaced.  For
             example, the following command will copy the list of files and
             directories which start with an uppercase letter in the current
             directory to destdir:

                   /bin/ls -1d [A-Z]* | xargs -J % cp -rp % destdir

论坛徽章:
0
3 [报告]
发表于 2007-03-16 14:45 |只看该作者
ns# find . -name "*.htm" | xargs -J grep -l "http://%7" {} ;
xargs: illegal option -- l
usage: xargs [-0opt] [-E eofstr] [-I replstr [-R replacements]] [-J replstr]
             [-L number] [-n number [-x]] [-P maxprocs] [-s size]
             [utility [argument ...]]
ns#
不得行。。。

论坛徽章:
0
4 [报告]
发表于 2007-03-16 14:46 |只看该作者
我想查找某部分文件内容中是否喊有某个字符或者某字符串,并且打印出这些文件名
这个是我要实现的功能,在linux下可以用find . -name "*.htm"|xargs -i grep -l "ffmail" {}|more这样实现
但bsd下就不行,请高手指点……

论坛徽章:
0
5 [报告]
发表于 2007-03-16 14:48 |只看该作者
http://www.freebsd.org/cgi/man.c ... ASE&format=html
这里man我看不明白。
ns# find . -name "*.htm" | xargs -J grep -l "http://%7" {}
xargs: illegal option -- l
usage: xargs [-0opt] [-E eofstr] [-I replstr [-R replacements]] [-J replstr]
             [-L number] [-n number [-x]] [-P maxprocs] [-s size]
             [utility [argument ...]]
ns#

论坛徽章:
0
6 [报告]
发表于 2007-03-16 14:51 |只看该作者
xargs -I % grep -l http://%7 %


J 替换一次...I 可以 配合-x替换多次

[ 本帖最后由 Edengundam 于 2007-3-16 14:55 编辑 ]

论坛徽章:
0
7 [报告]
发表于 2007-03-16 14:51 |只看该作者
xargs -I{} grep -l "ffmail" {}

不过-I这个参数可能有BUG,到您系统下的man xargs确认一下是否还需要其他参数增大最大输入行。

论坛徽章:
0
8 [报告]
发表于 2007-03-16 14:54 |只看该作者
grep: insert_image.php: No such file or directory
xargs -J % grep -l http://%7 % 用这个
提示grep: insert_image.php: No such file or directory

论坛徽章:
0
9 [报告]
发表于 2007-03-16 14:56 |只看该作者
ns# find /home/user -name "*.php"|xargs -I{} grep -l "http://%7" {}
xargs: illegal option -- l
usage: xargs [-0opt] [-E eofstr] [-I replstr [-R replacements]] [-J replstr]
             [-L number] [-n number [-x]] [-P maxprocs] [-s size]
             [utility [argument ...]]
ns#

论坛徽章:
0
10 [报告]
发表于 2007-03-16 14:58 |只看该作者
原帖由 Edengundam 于 2007-3-16 14:51 发表
xargs -I % grep -l http://%7 %


J 替换一次...I 可以 配合-x替换多次

xargs -I %  grep -l http://%7 %
这两个%是配对 的?
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP