Skip to main content
1 of 3
Priyanka
  • 31
  • 1
  • 3

Remove and replace between two specific strings using sed command

Hi I have a SQL file i wanted to remove case statements which are present in a single line as well as case statements which are present in multiple lines

For Example:- My Input File is:- Select a, b, c, CASE when e in (1,0,2) then Y END as e f, g, h, case when i in (5, 6, 7, 9. ,10) then N END as i FROM ABCD

In my output it shud be Select a, b, c, e as e f, g, h, i as i FROM ABCD

I m using sed command sed -i 's/\bCASE\b.*\bEND\b/${FIELD}/' $FILE but this is working only for case and end statement which are on single line I want to make it work for case and end statements which are multiple lines too

Priyanka
  • 31
  • 1
  • 3