一、字符截取

expr

基本用法

expr  substr   $var1   起始位置    截取长度,如:

[root@localhost mnt]# a=Centos6.9
[root@localhost mnt]#
[root@localhost mnt]# expr substr $a 1 6
Centos

cut

基本用法:

命令输出   |  cut  -c  起始位置-结束位置

命令输出   |  cut   -d  分隔符"  -f 字段编号

[root@localhost mnt]# a=Centos6.9
[root@localhost mnt]#
[root@localhost mnt]# expr substr $a 1 6
Centos

[root@localhost mnt]# echo $a
Centos6.9
[root@localhost mnt]# echo $a |cut -d 't' -f2
os6.9

 

相关文章:

  • 2021-11-04
  • 2022-02-26
  • 2022-12-23
  • 2021-06-13
  • 2021-04-08
  • 2022-12-23
  • 2022-12-23
  • 2021-12-13
猜你喜欢
  • 2022-01-12
  • 2022-12-23
  • 2022-12-23
  • 2021-08-10
  • 2021-10-05
  • 2021-04-13
  • 2021-09-19
相关资源
相似解决方案