Skip to content
Advertisement

sed fails with errors

I’m trying to replace the next string with sed in all the files in the current directory : (including apostrophe) ‘Control_Reports_Pg.C_Table_Title_Date’

with the string : timeofday()::varchar(250)

I tried to escape the special characters ‘ ( ) with the command :

sed -i '''Control_Reports_Pg.C_Table_Title_Date''/timeofday()::varchar(250)/g' *

The error I got : sed: -e expression #1, char 22: unknown command:_’

I read online that I dont need to escape underscore so what can I do ? When I try to escape underscore with i also get an error :

sed -i 'Pg.C_Table_Title_Date''/timeofday()::varchar(250)/g' *
sed: -e expression #1, char 24: unknown command: `'

Thanks..

Advertisement

Answer

Try this:

sed -i.bak "s/'Control_Reports_Pg.C_Table_Title_Date'/timeofday()::varchar(250)/g" *

Never hurts to make a backup file ;}

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement