How can I capitalize the first letter of each word?

前端 未结 20 2336
暖寄归人
暖寄归人 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:54

    bash:

    $ X=(hello world)
    $ echo ${X[@]^}
    Hello World
    
    0 讨论(0)
  • 2021-01-14 12:55

    ruby:

    irb> foo = ""; "foo bar".split.each { |x| foo += x.capitalize + " " }
    => ["foo", "bar"]
    
    irb> foo
    => "Foo Bar "
    
    0 讨论(0)
提交回复
热议问题