?? ex45a.sh
字號:
#!/bin/bashechoecho "String operations using \"expr \$string : \" construct"echo "==================================================="echoa=1234zipper5FLIPPER43231echo "The string being operated upon is \"`expr "$a" : '\(.*\)'`\"."# Escaped parentheses grouping operator. == ==# ***************************#+ Escaped parentheses#+ match a substring# ***************************# If no escaped parentheses...#+ then 'expr' converts the string operand to an integer.echo "Length of \"$a\" is `expr "$a" : '.*'`." # Length of stringecho "Number of digits at the beginning of \"$a\" is `expr "$a" : '[0-9]*'`."# ------------------------------------------------------------------------- #echoecho "The digits at the beginning of \"$a\" are `expr "$a" : '\([0-9]*\)'`."# == ==echo "The first 7 characters of \"$a\" are `expr "$a" : '\(.......\)'`."# ===== == ==# Again, escaped parentheses force a substring match.#echo "The last 7 characters of \"$a\" are `expr "$a" : '.*\(.......\)'`."# ==== end of string operator ^^# (actually means skip over one or more of any characters until specified#+ substring)echoexit 0
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -