piwik

dimarts, 4 de juny del 2013

Usefull hacks for grep command.

How to count the number of lines that match with a specific pattern in a file:
grep -c Josep /etc/passwd
Using -v option, we'll be inverting the results. The number of lines that do not match the pattern will be shown.
grep -cv Josep /etc/passwd
Ignoring case sensitive:
grep -i josep /etc/passwd

Searching through all subdirectories the files that inside them have at least one occurrence of the pattern.
grep -r mysql /home/josep

Cap comentari:

Publica un comentari a l'entrada