How to use non-capturing groups in grep?

“Non-capturing” doesn’t mean that the group isn’t part of the match; it means that the group’s value isn’t saved for use in back-references. What you are looking for is a look-behind zero-width assertion: grep -Po “(?<=syntaxHighlighterConfig\.)[a-zA-Z]+Color” file

Using grep with regular expression to filter out matches

The problem is that by default, you need to escape your |’s to get proper alternation. That is, grep interprets “foo|bar” as matching the literal string “foo|bar” only, whereas the pattern “foo\|bar” (with an escaped |) matches either “foo” or “bar”. To change this behavior, use the -E flag: tail -f logFile | grep -vE … Read more

Grep for beginning and end of line?

The tricky part is a regex that includes a dash as one of the valid characters in a character class. The dash has to come immediately after the start for a (normal) character class and immediately after the caret for a negated character class. If you need a close square bracket too, then you need … Read more

How to escape parenthesis in grep

It depends. If you use regular grep, you don’t escape: echo ‘(foo)’ | grep ‘(fo*)’ You actually have to escape if you want to use the parentheses as grouping. If you use extended regular expressions, you do escape: echo ‘(foo)’ | grep -E ‘\(fo*\)’

How to grep with a list of words

You need to use the option -f: $ grep -f A B The option -F does a fixed string search where as -f is for specifying a file of patterns. You may want both if the file only contains fixed strings and not regexps. $ grep -Ff A B You may also want the -w … Read more

How can I grep hidden files?

Please refer to the solution at the end of this post as a better alternative to what you’re doing. You can explicitly include hidden files (a directory is also a file). grep -r search * .[^.]* The * will match all files except hidden ones and .[^.]* will match only hidden files without … However … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)