How to convert a string to lower case in Bash?

前端 未结 20 2025
慢半拍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 09:53

    You can try this

    s="Hello World!" 
    
    echo $s  # Hello World!
    
    a=${s,,}
    echo $a  # hello world!
    
    b=${s^^}
    echo $b  # HELLO WORLD!
    

    ref : http://wiki.workassis.com/shell-script-convert-text-to-lowercase-and-uppercase/

提交回复
热议问题