Handling single and double quotes using SED

Lets say I have a file test.txt which contains the following:

This or ‘is nothing or’ or “that or” if it is or

Now I would like to replace the or which are not present in the quotes(either single quote or double quote). I want to achieve this by using SED. So my Input would look like: This or ‘is nothing or’ or “that or” if it is or
and output would be like : This OR ‘is nothing or’ OR “that or” if it is OR

I assume this is achievable by using awk, but can anyone do this using sed.
I am doing this on cygwin.


Source: regex

Leave a Reply