Linux shell 截取字符变量的前8位,有方法如下:

a="123456789012345"
expr substr "$a" 1 8
echo $a|cut -c1-8
echo $a|dd bs=1 count=8 2>/dev/null

方法整理自:https://www.cnblogs.com/liuweijian/archive/2009/12/27/1633661.html

Related Posts: Shell 字符串截取示例 :

avatar