How to convert a string to lower case in Bash?

前端 未结 20 2026
慢半拍i
慢半拍i 2020-11-22 09:40

Is there a way in bash to convert a string into a lower case string?

For example, if I have:

a=\"Hi all\"

I want to convert it to:<

20条回答
  •  情歌与酒
    2020-11-22 10:19

    Using GNU sed:

    sed 's/.*/\L&/'
    

    Example:

    $ foo="Some STRIng";
    $ foo=$(echo "$foo" | sed 's/.*/\L&/')
    $ echo "$foo"
    some string
    

提交回复
热议问题