find exec 用法- -

在linux 里man find 里有一段说明:


  -exec command ;
    Execute  command;  true  if 0 status is returned.  All following
    arguments to find are taken to be arguments to the command until
    an  argument  consisting of `;' is encountered.  The string `{}'
    is replaced by the current file name being processed  everywhere
    it occurs in the arguments to the command, not just in arguments
    where it is alone, as in some versions of find.  Both  of  these
    constructions might need to be escaped (with a `\') or quoted to
    protect them from expansion by the shell.  The command  is  exe-
    cuted in the starting directory.

意思是说可以在FIND后调用外部命令,不过,由于英语难懂,一时很难理解。且没EXAMPLE,试验后如下:

 

find . -name "*.jsp" -exec grep 192.168.80.197  {} -H \;


这条命令的意思是,查当前目录以下包括各个子目录中所有jsp文件,并用GREP查代里面含有“192.168.80.197”字样,并把这个文件名显示出来。

另外,要注意的是,在使用时,经常遇到 find: missing argument to `-exec'
这个意思并不是说没有exec参数,而是exec后面的参数不对。这时,应该检查\;之前有没有空格之类

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值