编辑代码

#JSRUN引擎2.0,支持多达30种语言在线运行,全仿真在线交互输入输出。
# test1='I am test1.'
# echo $test1
# test2='I am test2, i have '$test1'!'
# echo $test2

# test1='I am test1'
# test2="Hi, i am test2,i have "$test1"!"
# echo $test2

# test1='I am test1'
# # 获取字符串长度方式1
# echo ${#test1}
# # 获取字符串长度方式2
# expr length "$test1"

# expr 5+6
# expr 5 + 6

# expr 5 * 6  # 输出错误
# expr 5 \* 6

# 截取
# str="Hi, i am a str.Please tell me, where are you?"
# echo ${str:0:10}

# str="https://www.baidu.tenxunjagegsetoemgwglmldo.com.htm"
# %
# s1=${str%t*}
# echo $s1

# %%
# s2=${str%%t*}
# echo $s2
# s4=${str%%.*}
# echo $s4

# #
# s3=${str#*/}
# echo $s3
# s5=${str##*/}
# echo $s5

array=(1 2 3 4 5);
# length=${#array[@]}
# echo $length

# length2=${#array[*]}
# echo $length2

# echo ${array[3]}
# unset array[1]
# length3=${#array[*]}
# echo $length3

# for i in ${array[@]};do echo $i;done  # 遍历数组

# unset array;  // 删除数组所以元素
# for i in ${array[@]};do echo $i;done