SED help with first character in line.
So I have this sed command that will replace " l " with " I " and fix many other l and I mistakes. I have this script running through subtitles and it has worked great so far. The problem that I am running into is when the first letter is a lower case L and should be and upper case I.
Code:
6 Code:
sed 's/ l / I /g' $i.b > $i.a Is there a way I can have it change l to I if its at the beginning of a sentence? Thanks mac |
Simply tell sed that you may have leading space(s) (and perhaps trailing ones) or you can have a look at word boundaries.
Check here for more information. |
To get the most out of commands like sed, you should learn how to use regular expressions. In this case you "anchor" the pattern to the beginning of the line with "^".
Code:
sed 's/^l /I /g' "$i.b" > "$i.a" Here are a few regular expressions tutorials: http://mywiki.wooledge.org/RegularExpression http://www.grymoire.com/Unix/Regular.html http://www.regular-expressions.info/ |
Thanks, that worked.
|
All times are GMT -5. The time now is 06:14 PM. |