I have strings per line like:
" ... "es" completed."
" ... "en" completed."
" ... "fr" completed."
I am trying to grep inverse match of all this. That is avoid output all the lines that match with the pattern.
echo " ... "es" completed." | grep -v " ... "(*)" completed."
echo " ... "es" completed." | grep -v " ... "[*]" completed."
echo " ... "en" completed." | grep -v " ... "[\w]" completed."
echo " ... "fr" completed." | grep -v " ... "[\W]" completed."
All this grep ways still output the strings, I don't know if I need use -e as option parameter, but I am not getting the desired result
1 Answer 1
-e PATTERN, --regexp=PATTERN Use PATTERN as the pattern. This can be used to specify multiple search patterns, or to protect a pattern beginning with a hyphen (-). (-e is specified by POSIX .)
Yes, you should use -e. But also regex up, especially with double quotes in double quotes, dots and asteriks.
Lets say I do not want any line that ends with completed.
| grep -v -e '.*completed\.$'
- $ end of string or line
- * zero or more occurences
- . matches almost everything
- \ escape characters, in this case .
-
I gonna try, the problem is that there is more "completed" strings, so I really need the full regex. Also notice that the double quotes are not normal like ", are " (probably difficult to notice)shakaran– shakaran2017年09月14日 00:24:11 +00:00Commented Sep 14, 2017 at 0:24
-
1It seems that grep -v -e " ... ".*" completed\.$" work perfect ;)shakaran– shakaran2017年09月14日 00:27:36 +00:00Commented Sep 14, 2017 at 0:27
" ... ".." completed\."
- not a "wildcard"