字符串也是必须有的。
字符串的长度
bash script 获取字符串长度的方法是如此的简单直接而耐人寻味。
#!/bin/bash
Str="Welcome to fosslinux.com"
echo "Length is: ${#Str}"
连接字符串
这才叫简单直接。
#!/bin/bash
string1="foss"
string2="linux.com"
string=$string1$string2
echo "$string is a great website."
截取不叫截取而叫Extracting
#!/bin/bash
Str="Welcome to the fosslinux.com"
# Extracting string from index 15
echo ${Str:15}
# Extracting string from index 15 of length 5
echo ${Str:15:5}
网友评论