首页 > 系统服务 > 详细

shell学习(四)

时间:2018-04-20 17:23:39      阅读:160      评论:0      收藏:0      [点我收藏+]

一、字符截取

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学习(四)

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!