1

MY File:

"DocumentCreationDate="2019-07-15T23:56:31" SampleID="1" entClassID="65535" ClientID="0" CardID="11209797""

Want to grep Pattern :

CardID="11209797"

The number may be different between " "

Command used : egrep -o CardID='\"[^]"*]'

OUTPUT : CardID="1

Desired Outpt: CardID="11209797"

2

Try this,

grep -o 'CardID="[^"]*"' file
CardID="11209797"
1
$ grep -Eo 'CardID="[^"]*"' file
CardID="11209797"

Notes:

  1. egrep is deprecated. Use grep -E instead.

  2. Inside single-quotes, " does not need to be escaped.

  3. [^]"*] matches any one character that is not ], ", or *. What you want instead is to any series of characters except ". To do that, use [^"]*.

2
  • Your regexp is a BRE, no need for -E to enable EREs.
    – Ed Morton
    Jul 16 '19 at 13:09
  • 1
    worked , resolved Jul 17 '19 at 3:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.