There's a way to do it in perl:
Code:
echo "hello. my name is newbe.can u help me?" | perl -e 'while (<>) { s/^(\s*.)/\U$1/;s/([[:punct:]]\s*.)/\U$1/g;print}'
There might be a more efficient way. Basically that is a short program jammed into a single line.
Code:
while (<>) { # read from stdin until no more input
s/^(\s*.)/\U$1/; # substitute
s/([[:punct:]]\s*.)/\U$1/g; # global substitute, pattern starts with punctuation
print
}
All that takes effect on the default variable of perl, $_ which is implied if it is not written.
Bookmarks