0

I need the below requirement

string123

stringsecond

string-third

-string-four

string_five

/string/

sixstring

this should not print

output

string-third

-string-four

string_five

/string/

So as per the output,the command should not grep string followed with alphanumeric only. I am using -w option with grep ,but it is eliminating underscore(_) strings also.

Rakesh Talari
  • 71
  • 1
  • 6

1 Answers1

0

Use a negated character class at the end of your regex.

If you're matching "string", then append a class like [^0-9a-zA-Z_] to the end.

aghast
  • 14,785
  • 3
  • 24
  • 56