shell 字符串
2016-02-22 22:49
309 查看
字符串可以分为单引号,双引号,也可以不用引号
单引号
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}
单引号
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}
相关文章推荐
- PowerShell 在线教程
- 常用shell命令
- linux下shell编程示例-获取进程id
- linux下使用shell脚本自动化部署项目
- shell脚本基础知识和位置变量
- monkey离线运行之shell脚本实现
- pc进入android手机shell的root权限(su: not found)
- 读取系统执行状态的shell脚本
- 【FAQ】bash VS dash 字符串正则表达式匹配
- Shell 自定义颜色输出函数
- shell script中奇怪的符号之${0##*/}
- Linux shell脚本 基础知识总结
- Linux笔记(11)——Shell脚本执行
- Linux笔记(10)——Shell概述
- Windows 下/bin/bash: line 0: fg: no job control一般解决方法
- shell 读取文件内容
- Shell脚本中的for,while用法
- linux shell:nginx日志切割脚本
- shell中后台运行函数
- shell十三问