I am trying to create a sed command that capitalizes the pronoun I in a text file. For example "i like dogs." should be "I like dogs." So far I have:
sed 's/ i / I /g'
This doesn't work in a number of different scenarios. Like if there is punctuation around the i.
Here's a list of scenarios that I have thought of that the command should be able to handle:
- There are multiple 'i's on one line of text. I think this can be addressed just by having the
g
flag at the end. - The 'i' has punctuation around it. For example a comma or period after it, or a quote or parenthesis before or after it.
- The 'i' is the first or last character on the line. Meaning you couldn't just check for whitespace or punctuation around it.
- Any regular 'i's in a word are left alone. For example "firefighter" shouldn't be turned into "fIrefIghter".