I'd like to do a wholesale reformatting of our tests, and I'm cleaning up some inconsistent capitalization. I'm thinking of using awk to do this, since sed falls a little short, and since I need lookahead for my case. Specifically, for each line in a given file, I want the following to happen:
Look for the word
it,describe, orcontext, followed by a space, followed by a single or double quote mark, followed by an uppercase alphabetic character.If there's a match, substitute the match with the lowercased version of the entire matched string, but only the matched string (don't lowercase other things on the same line).
Don't match if the string after the single or double quote mark is one of "GET", "POST", "PUT", or "DELETE".
So, for example:
describe 'apple banana' ----> (no change)
describe 'APPLE BANANA' ----> describe 'aPPLE BANANA'
describe 'Apple Banana' ----> describe 'apple Banana'
describe "Apple Banana" ----> describe "apple Banana"
describe 'one TWO' ----> (no change)
context 'POST BANANA' ----> (no change)
context 'XPOST BANANA' ----> context 'xPOST BANANA'
What awk arguments and/or other commands should I use? (It's okay with me if it requires more than one pass to do it.)
it,describe, orcontextalways be the first word on the line? Will there always be exactly two words between the quotes? – Scott Oct 1 '12 at 19:54it,describe, andcontextwill always be the first word, but they may not start that line. (2) There might be many words between the quotes. – John Feminella Oct 2 '12 at 2:21