How can I capitalize the first letter of each word?

前端 未结 20 2321
暖寄归人
暖寄归人 2021-01-14 12:31

I need a script in any language to capitalize the first letter of every word in a file.

Thanks for all the answers.

Stackoverflow rocks!

20条回答
  •  囚心锁ツ
    2021-01-14 12:37

    Using the non-standard (Gnu extension) sed utility from the command line:

    sed -i '' -r 's/\b(.)/\U\1/g' file.txt
    

    Get rid of the "-i" if you don't want it to modify the file in-place.

    note that you should not use this in portable scripts

提交回复
热议问题