How to grep and count on a single go?
Hi,
Is it possible to do a grep and do the count for number of occurrence? Say, am going for this Code:
grep zamo */*/* Thanks |
If you use grep -c, you'll get a count for each file, and then you'd have to add it. I guess doing a grep first and then piping it to wc is the easiest way. You can redirect stderr to /dev/null to skip error messages:
Code:
grep zamo */*/* 2>/dev/null | wc -l |
check the -c option
|
Thanks Arun, I forgot the -c switch . Further do "2>/dev/null " can supress any error to print on screen? Is it?
|
Yes, that command prevents errors from appearing on the screen by redirecting them to /dev/null. You could redirect it to a file for later reading too, if you use something like "2>/tmp/grep-errors.txt". Either way it won't appear on screen.
|
All times are GMT -5. The time now is 07:21 AM. |