获取字符串最后几个字母
echo "hello" | tail -c 5
ellosomeone@mypc:~$ str="A random string*"; echo "$str"
A random string*
someone@mypc:~$ echo "${str:$((${#str}-1)):1}"
*
someone@mypc:~$ echo "${str:$((${#str}-2)):1}"
gecho -n "hello" | tail -c 4 | head -c 1参考
Last updated