0

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
  • You need to use a regular expression that matches the strings, for example, " … “..” completed\." - not a "wildcard" Sep 13, 2017 at 23:40

1 Answer 1

2

-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 .
2
  • 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
    Sep 14, 2017 at 0:24
  • 1
    It seems that grep -v -e " … “.*” completed\.$" work perfect ;)
    – shakaran
    Sep 14, 2017 at 0:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .