Character Lowercase to Uppercase in Shell Scripting

前端 未结 3 382
天涯浪人
天涯浪人 2021-01-23 11:46

I have value as: james,adam,john I am trying to make it James,Adam,John(First character of each name should be Uppercase)

According to

相关标签:
3条回答
  • 2021-01-23 12:04

    You can use sed:

    $ echo 'james,adam,john' | sed 's/\<./\u&/g'
    James,Adam,John
    
    • pattern \<. will match first char of every word
    • use \u& to make it uppercase.
    0 讨论(0)
  • 2021-01-23 12:04

    There are endless possibilities, but look up tr and shell string substitution (if your shell supports it). Then there's GNU sed, awk, perl and many other languages ...

    0 讨论(0)
  • 2021-01-23 12:06

    Using bash:

    A="james adam john"
    B=( $A )
    echo "${B[@]^}"
    

    Output is:

    James Adam John
    
    0 讨论(0)
提交回复
热议问题