4 ms·
Is there any benefit of cat files* | grep pattern over this grep -h pattern files* aside from result color highlighting?
by sm4rk0 7y ago
Is there any benefit of
cat files* | grep pattern
over this
grep -h pattern files*
aside from result color highlighting?
- sm4rk0 7y agoI've read this, but still can't see a reason to use 'cat | grep': https://stackoverflow.com/questions/13507889/difference-between-grep-vs-cat-and-grep https://stackoverflow.com/questions/13507889/difference-betw...
- bewuethr 7y agoI don't think there is.
- protanopia 7y agoWith the first method, you can use xargs to run multiple copies of grep running in parallel like he did later in the article.
- nemetroid 7y agoThe author switched to using find before doing the parallelization.
- parliament32 7y agoEven though it's a faux pas, I find it logically makes more sense to me. Consider a pipeline like cat *.log | grep "apache" | grep -v "1.1.1.1" | wc -l It makes sense in that order. Read the file, grep this, exclude that, could the total. Meanwhile grep "apache" *.log | grep -v "1.1.1.1" | wc -l may be a few characters shorter but the order isn't really logical anymore.