You need to pass the -c or --count option to suppress normal output. It will display a count of matching lines for each input file:
$ grep -c vivek /etc/passwdOR
$ grep -w -c vivek /etc/passwdSample outputs:
1However, with the -v or --invert-match option it will count non-matching lines, enter:
$ grep -c vivek /etc/passwdSample outputs:
45
No comments:
Post a Comment