码迷,mamicode.com
首页 > 系统相关 > 详细

shell学习(四)

时间:2018-04-20 17:54:05      阅读:165      评论:0      收藏:0      [点我收藏+]

标签:bsp   bst   str   结束   root   centos6   centos   local   字符截取   

一、字符截取

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

 

shell学习(四)

标签:bsp   bst   str   结束   root   centos6   centos   local   字符截取   

原文地址:https://www.cnblogs.com/heruiguo/p/8386281.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!