I need to replace single quotes with double quotes AND double quotes with single quotes in over 600 files. I've been reading various topics most of the day. I am hampered by only knowing some basic shell scripting commands and an unfamiliarity with regexp.
Below is a sample file I've made a bit generic.
some text KEYWORD_1 table name column = "string" AND column = "string" Additional text . . . some text KEYWORD_2 text 'text in quote' etc.
I only want to change the quotes on the 2 lines with KEYWORDs. I can't guarantee the keywords are always going to be first line and last line. I need my solution to find the keyword and change all the quotes on that line only.
I tried some things I found in sort of similar questions on this forum, including a meta on SED. I tried to figure out how to use this command:
sed -i 's/foo\(.*baz\)/bar\1/' file. According to that topic the command, "Replaces foo with bar only if there is a baz later on the same line." My keyword is not later on the same line its at the beginning and I couldn't make it work for me.
I also tried
ex -sc 'g/DEL/s/ALF/BRA/g' -cx file that didn't do anything. I'm assuming it can't be executed from the command line. I really don't want to open each of 600 files.
At one point I tried,
grep KEYWORD_1 file | sed -i "s/'/\"/g" file
Of course, that changed all the quotes in the file not just the one line.
I'm betting the solution is simple and I just can't see it. How can I do this?
As requested my desired output is:
some text KEYWORD_1 table name column = 'string' AND column = 'string' Additional text . . . some text KEYWORD_2 text "text in quote" etc.