I need to change the first letter of every line in a file to uppercase, e.g.
the bear ate the fish.
the river was too fast.
Would become:>
Use sed:
sed 's/^\(.\)/\U\1/' yourfile > convertedfile
Little explanation:
^ represents the start of a line.. matches any character\U converts to uppercase\( ... \) specifies a section to be referenced later (as \1 in this case); parentheses are to be escaped here.Do not try to redirect the output to the same file in one command (i.e. ) as you will lose your data. If you want to replace in the same file then check out joelparkerhenderson's answer.> yourfile