regex - Convert first letters of the first 2 words to Upper using sed -
i know can awk, want know how sed. know how convert first letter of each line upper:
sed 's/^\(.\)/\u\1/' input > output
but want convert first letters of first 2 words upper.
input file:
this file
output file:
this file
i think must doable sed, can't figure out.
you can maybe use -e
2 blocks:
$ echo "this file" | sed -e 's/^\(.\)/\u\1/' -e 's/ \(.\)/ \u\1/' file ^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^ first word second word
note can make lines more clear -r
parameter allows catching simple (xxx)
instead of \(xxx\)
:
$ echo "this file" | sed -re 's/^(.)/\u\1/' -e 's/ (.)/ \u\1/' file
Comments
Post a Comment