Escaping or ignoring a forward slash in vi

I was having to update some dates to change the format in a SQLite table, and when doing the replace, I thought this could be a useful tip and give a demonstration on how to do a global replace when some of the text contains /.

Below is the text and the code, I had already replace the first dates was is easy, however as there are / in the second date format you need to escape them first using a back slash \.

update tp_team_days set day = '2018-04-27' where day = '27/01/2018';
update tp_team_days set day = '2018-04-28' where day = '28/01/2018';
update tp_team_days set day = '2018-04-29' where day = '29/01/2018';
update tp_team_days set day = '2018-04-30' where day = '30/01/2018';
update tp_team_days set day = '2018-04-31' where day = '31/01/2018';
~

:1,$s/\/01\//\/04\//g

So with the command above, you can see how to use the escape so you can change /01/ to /04/.

At first when you do this is looks daunting, but after a few goes it seems easier.

If you need any more help or explanation, please feel free to get in touch.

I am always interested in feedback so please feel free to add any comments, or you can mail me  here.  If you would like to submit a quick tip  with full credit and links back to your site then also feel free to contact me.

Related Posts Plugin for WordPress, Blogger...
Reduce jpg size using preview

Reduce jpg size using preview

Ansible script to drop a user