linux grep将输出写入文件

Raj*_*esh 8 linux grep

find . -name "*.php" | xargs grep -i -n "searchstring" >output.txt
Run Code Online (Sandbox Code Playgroud)

在这里,我试图将数据写入一个没有发生的文件...

dar*_*ioo 10

如何使用附加结果>>

find . -name "*.php" | xargs grep -i -n "searchstring" >> output.txt
Run Code Online (Sandbox Code Playgroud)

我现在还没有带有Linux的盒子,所以我会尝试即兴创作.

xargs grep -i -n "searchstring"困扰我一下.

也许你的意思xargs -I {} grep -i "searchstring" {},或者只是xargs grep -i "searchstring"

由于-ngrep的参数只给你数字线,我怀疑这是你需要的.

这样,你的最终代码就是

find . -name "*.php" | xargs grep -i "searchstring" >> output.txt
Run Code Online (Sandbox Code Playgroud)


Mik*_*kel 0

对我来说看起来不错。如果删除会发生什么>output.txt