how do I use the grep –include option for multiple file types?

You can use multiple –include flags. This works for me: grep -r –include=*.html –include=*.php –include=*.htm “pattern” /some/path/ However, you can do as Deruijter suggested. This works for me: grep -r –include=*.{html,php,htm} “pattern” /some/path/ Don’t forget that you can use find and xargs for this sort of thing too: find /some/path/ -name “*.htm*” -or -name “*.php” … Read more

grep regex whitespace behavior

This looks like a behavior difference in the handling of \s between grep 2.5 and newer versions (a bug in old grep?). I confirm your result with grep 2.5.4, but all four of your greps do work when using grep 2.6.3 (Ubuntu 10.10). Note: GNU grep 2.5.4 echo “foo bar” | grep “\s” (doesn’t match) … Read more

How to delete rows from a csv file based on a list values from another file?

What about the following: awk -F, ‘(NR==FNR){a[$1];next}!($1 in a)’ blacklist.csv candidates.csv How does this work? An awk program is a series of pattern-action pairs, written as: condition { action } condition { action } … where condition is typically an expression and action a series of commands. Here, the first condition-action pairs read: (NR==FNR){a[$1];next} if … Read more

Grepping for exact words with UNIX

Use whole word option: grep -c -w aaa $EAT_Setup_BJ3/Log.txt From the grep manual: -w, –word-regexp Select only those lines containing matches that form whole words. The test is that the matching substring must either be at the beginning of the line, or preceded by a non-word constituent character. As noted in the comment -w is … Read more