1

my file contains:

/*uid:68160*/\n            SELECT
/*uid:68160*/SELECT

I tried with below:

grep -vF "/[*]uid::[[:digit:]][*]/SELECT"

which is helping to removed 2nd line. How to remove 1st line by grep also tried:

grep -vF "/[*]uid::[[:digit:]][*]/\n            SELECT"
ceving
  • 21,900
  • 13
  • 104
  • 178

1 Answers1

1

Assuming you have a literal text like that,

s='/*uid:68160*/\n            SELECT
/*uid:68160*/SELECT
Text'

and you want to remove lines 1 and 2, you may use

 grep -Ev '/[*]uid:[[:digit:]]+[*]/(\\n *)?SELECT'

See the online grep demo

Details

  • -Ev - E enables POSIX ERE and v will negate the result
  • /[*]uid:[[:digit:]]+[*]/(\\n *)?SELECT - matches
    • /[*]uid: - a /*uid: string
    • [[:digit:]]+ - 1+ digits
    • [*]/ - a */ string
    • (\\n *)? - an optional group matching 1 or 0 occurrences of \n two-char combination and then any 0 or more spaces
    • SELECT - a string
Wiktor Stribiżew
  • 607,720
  • 39
  • 448
  • 563