linux中提取变量的指定个字符
1、举例
root@DESKTOP-1N42TVH:/home/test3# a="aa.bb.cc.dd" root@DESKTOP-1N42TVH:/home/test3# echo $a aa.bb.cc.dd root@DESKTOP-1N42TVH:/home/test3# echo ${a:0:5} ## 提取变量a左侧的5个字符 aa.bb
root@DESKTOP-1N42TVH:/home/test3# echo $a aa.bb.cc.dd root@DESKTOP-1N42TVH:/home/test3# echo ${a:5:5} ## 前5个字符之后的连续5个字符 .cc.d
参考:https://blog.csdn.net/qq_30130417/article/details/80911989

浙公网安备 33010602011771号