Reputation: 24130
I have a problem with redirecting output from xargs namely I do something like:
find . -mmin -10 | xargs grep mypattern > greping
This will keep writing to file indefinitely (I have waited until file reached around 25GB ) but when I change it to add pipe to grep at the end I will get proper results ( around 25 kB file ):
find . -mmin -10 | xargs grep mypattern | grep 2013-07-11 > greping
What am I missing here and why does xargs
in first code snippet keep writing to file ?
Bash version GNU bash, version 4.1.2(1)-release (x86_64-redhat-linux-gnu)
Upvotes: 0
Views: 1436
Reputation: 20980
Change redirected file from >greping
to >../greping
or >/tmp/greping
.
Basically, output file should not be in current directory or any of its subdirectory.
Or try:
find . -mmin -10 | grep -Fx -v './greping' | xargs grep mypattern > greping
Upvotes: 3