String Manipulation 字串處理
字串長度
my_string="abhishek"
echo "length is ${#my_string}"
Using expr
str="my string"
length=$(expr length "$str")
echo "Length of my string is $length"
Using awk
echo "my string" | awk '{print length}'
Using wc
str="my string"
length=$(echo -n "my string" | wc -m)
echo "Length of my string is $length"
字串比對