I want to change the first character of each line to upper case.
Sample input:
Desired output:
The brute force technique uses
cut to make two work files,
tr one of them to upper case, and
paste to arrive at the desired result. Googling in search of a more direct method I came upon this one:
Code:
sed 's/\([a-z]\)\([a-zA-Z0-9]*\)/\u\1\2/g' $InFile
It works but I don't understand it. Attempting to simplify this one-liner I tried this:
Code:
sed 's/\([a-z]\)\(.*\)/\u\1\2/' $InFile
This also works but why?!? The magic may lie in the
\u but what does that mean?
Daniel B. Martin