Read a file and replace a value- Bourne and Korn shell

Hello,

I have a file called Delete and within the delete file I have the following statement:

delete from employee where employee_id = " "

how do I write a script that read from this file and replace:

employee_id = " " with employee_id is null

Please assist...greatly appreciate it.

thanks,
kenix

Hi,

just type the below at $ prompt :

sed 's/employee_id = \" \"/employee_id is null/g' Delete > Delete.new

then check file Delete.new

Thanks
Krishna

Try :

l_var=`sed -e 's/employee_id = " "/employee_id is null/p' <filename> | head -n 1`

l_var is your string variable
<filename> is the file that contains your sql statement

is that what you were looking for?

cheers
:slight_smile:

Thank you everyone for your help.

This is very helpful to me. I will defintely try this.

Thanks,
Kenix:)