find 后调用 -exec 执行语句处理find出来的结果:
find /root -name tom_renam -exec grep -nR "hello" {} ;
但是我我现在想执行多个语句,怎么弄?
我本来想像下面这样,但是报错:
find /root -name tom_renam -exec echo {} &&grep -nR "hello" {} ;
有谁知道-exec 后面执行多条语句的方法吗?
find /root -name tom_rename -exec echo {} \; -exec grep -nR "hello" {} \;
for循环一行式 对find出来的多个文件进行批量处理
for i in `find /root -name tom_renam` ;do echo $i && grep -nR "hello" $i ;done
/root/tom_renam
1:hello
for i in `find /root -name "tom_renam*"` ;do echo $i && grep -nR "hello" $i ;done
/root/tom_renam
1:hello
/root/tom_renam2
3:hello