首页 > 系统服务 > 详细

shell 字符串

时间:2016-02-22 23:23:35      阅读:337      评论:0      收藏:0      [点我收藏+]

字符串可以分为单引号,双引号,也可以不用引号

单引号

str=‘this is string‘

单引号字符的限制:

单引号中的任何字符都会原样输出,单引号中变量是无效的

单引号中不能出现单引号

双引号:

str=“my name is ${name}”

双引号字符的优点:

双引号中可以有变量

双引号中可以出现转移字符

拼接字符串

your_name="qinjx"
greeting="hello, "$your_name" !"
greeting_1="hello, ${your_name} !"

echo $greeting $greeting_1

获取字符串的长度

str=“abcd”

echo ${#str}

提取子字符串

str=“this is my student”

echo ${string:1:3}

shell 字符串

原文:http://www.cnblogs.com/techdreaming/p/5208447.html

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