grep command
grep is the most use in unix os. i give some examples about grep using.
this is hello world of grep command. it search first argument in second argument directory.
if it is called with -i argument, it ignores lower and upper case.
-r argument is recursion argument. it search first argument in all directories in second argument directory.
when grep is called with -w argument, it search just first argument in directory, prevents words which contains first argument.
-c argument returns count of first argument in directory.
-n argument finds first argument in second argument and gets their line numbers.
-v argument reverse process logic of plain grep command, it gives lines which don't contain first argument.
-l argument list results.
–color argument colourize lines.
this is hello world of grep command. it search first argument in second argument directory.
- grep borjune /etc/passwd
if it is called with -i argument, it ignores lower and upper case.
- grep -i borjune /etc/passwd
-r argument is recursion argument. it search first argument in all directories in second argument directory.
- grep -r borjune /etc/passwd
- grep -w borjune /etc/passwd
-c argument returns count of first argument in directory.
- grep -c borjune /etc/passwd
-n argument finds first argument in second argument and gets their line numbers.
- grep -n borjune /etc/passwd
-v argument reverse process logic of plain grep command, it gives lines which don't contain first argument.
- grep -v borjune /etc/passwd
-l argument list results.
- grep -l borjune /etc/passwd
–color argument colourize lines.
- grep --color borjune /etc/passwd
-E parameter is used for extended grep operations. Its alias is egrep.
- grep -E 'word1|word2' directory