Skip to main content
edited body
Source Link
Philippos
  • 13.8k
  • 2
  • 42
  • 82

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, caseCASE when i in (5, 6, 7, 9. ,10) then N END as i FROM ABCD 

In my output it should be

Select a, b, c, e as e f, g, h, i as i FROM ABCD 

I'm using the 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.

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 should be

Select a, b, c, e as e f, g, h, i as i FROM ABCD 

I'm using the 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.

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 should be

Select a, b, c, e as e f, g, h, i as i FROM ABCD 

I'm using the 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.

code formatting and copy edits
Source Link
steeldriver
  • 83.9k
  • 12
  • 124
  • 175

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 Fileexample, 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

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 shudshould be Select a, b, c, e as e f, g, h, i as i FROM ABCD

Select a, b, c, e as e f, g, h, i as i FROM ABCD 

I mI'm using the sed command sed -i 's/\bCASE\b.*\bEND\b/${FIELD}/' $FILE but

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.

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

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 should be

Select a, b, c, e as e f, g, h, i as i FROM ABCD 

I'm using the 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.

Source Link
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