Bash Perl Tcl syntax diff
1. 进制数表示
Language | binary | octal | hexadecimal |
---|---|---|---|
bash | 2#[0~1] | 0[0~7] | 0x[0~f] or 0X[0~f] |
perl | 0b[0~1] | 0[0~7] | 0x[0~f] |
tcl | 0b[0~1] | 0o[0~7] | 0x[0~f] |
bash different base represntation reference
2. String length
Language | String length |
---|---|
bash | ${#variable_store_string} |
perl | length($variable_store_string) |
tcl | string length variable_store_string |
https://www.tutorialspoint.com/tcl-tk/tcl_strings.htm
3. String upper/lower
Language | String upper | String lower |
---|---|---|
bash | ${variable_store_string^^} | ${variable_store_string,,} |
perl | uc($variable_store_string) | lc($variable_store_string) |
tcl | string toupper variable_store_string | string tolower variable_store_string |
# perl
/u 修改下一个字符为大写
/l 修改下一个字符小写
/U 修改后面所有字符大写
/L 修改后面所有字符小写
/Q 使后面的所有字符都成为字面符号
/E 结束/U /L或/Q的效果
# =============================================================== #
perl bash tcl
ucfirst ${var^} string toupper 0/string totitle
lcfirst ${var,} string tolower 0
# bash
declare -l var="strings"
declare -u var="strings"
bash upper/lower blog reference
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/tech/pnotes/280528.html