type test
type -a test

math calculate:
echo $((1+2*3))

parameter expansition:
bash-4 introduced features:
var=student
echo ${var^}  //Student
echo ${var^^} //STUDENT
var=STUDENT
echo ${var,}  //sTUDENT
echo ${var,,} //student
bash2 introduced features:
${var//PATTERN/STRING}:replace all instances of pattern with string
passwd=12345678
printf "%s\n" "${passwd//?/*}" //********
${var:OFFSET:LENGTH}:return a substring of $var
var=student
echo ${var:0:3} //stu
POSIX SHELL
posix shell introduced some expansions from kornshell.
main returning the length and removing a pattern from the beginning
or end of a variable's contents.
${#var}:length of variable's contents
var=student
echo "${#var}" //7
${var%PATTERN}:remove the shortest match from the end
var=tomorrow
echo ${var%o*} //tomorr
${var%%PATTERN}:remove the longgest match from the end
var=tomorrow
echo ${var%%o*} //t
${var#PATTERN}:remove the shortest match from the beginning
var=tomorrow
echo ${var#*o} //morrow
${var##PATTERN}:Remove the longest match from the beginning
echo ${var##*o} //w

${var:-default} and ${var-default}: use default values
${var:-default}
if the var is unset or empty, then use default
var=
echo ${var:-default} //default
unset var
echo ${var:-default} //default
${var-default}
if the var is unset , then use default , just this case
unset var
echo ${var-default} //default
var=
echo ${var-default} //

shell parameter expansitions的更多相关文章

  1. bash shell parameter expansion

    1 ${parameter%word}和${parameter%%word} ${parameter%word},word是一个模式,从parameter这个参数的末尾往前开始匹配.单个%进行最短匹配 ...

  2. Shell parameter expansion

    使用sh写一些小型的脚本会使工作更加简单.有部分内容可能大家都比較陌生(至少我是这样). 就是变量有关的參数展开,以下就是一些简单的描写叙述和使用方法.能够使代码更加简洁 展开运算符 替换运算 ${v ...

  3. SH Script Grammar

    http://linux.about.com/library/cmd/blcmdl1_sh.htm http://pubs.opengroup.org/onlinepubs/9699919799/ut ...

  4. 学习bash

    工作8年,前6年基本是Windows环境下,也就是个鼠标党:两年前换工作开始用linux,也就开始了领略了命令行的强大,无论是直接在命令行组合命令,也还写几行简单的shell脚本,其能完成的功能往往令 ...

  5. Bash Scripting Learn Notes

    References: [1] http://www.tldp.org/LDP/Bash-Beginners-Guide/html/ 1. Executing programs from a scri ...

  6. saltstack 基本操作

    一.常用操作 ①.模块查看 #查看全部模块 [root@k8s_master ~]# salt '*' sys.list_modules # "*"为所有node节点 (此处可以写 ...

  7. Linux environment variables (环境变量)

    Environment variables are often used to store a list of paths of where to search for executables, li ...

  8. Bash脚本编程之字符串处理

    简介 其实这里说得字符串处理,对应的是bash官网中的[Shell Parameter Expansion],不过直接去看这部分内容实在是太难以理解了.就按照马哥所说的字符串处理会比较好理解,平常使用 ...

  9. man bash

    BASH(1) General Commands Manual BASH(1) NAME bash - GNU Bourne-Again SHell SYNOPSIS bash [options] [ ...

随机推荐

  1. 微博关注/QQ信息发送

    <!doctype html> <html lang="en" xmlns:wb=“http://open.weibo.com/wb”> <head& ...

  2. Rafy 领域实体框架示例(1) - 转换传统三层应用程序

    Rafy 领域实体框架发布后,虽然有帮助文档,许多朋友还是反映学习起来比较复杂,希望能开发一个示例程序,展示如何使用 Rafy 领域实体框架所以,本文通过使用 Rafy 领域实体框架来改造一个传统的三 ...

  3. android Can't bind to local 86XX for debugger

    For some reason eclipse DDMS always gives the error 'Can't bind to local 86XX for debugger' every ti ...

  4. php strtotime 在32位操作系统下的限制

    php strtotime 在32位操作系统下的限制 <?php class DateHelper{ /** * 在32位操作系统下,超过 2038-01-19 03:14:07 ,会溢出 * ...

  5. JVM-绘图展现字节码执行引擎执行过程

    在我的上一篇博客JVM-String比较-字节码分析中介绍了String字符串比较的原因,借着分析字节码的机会,我这篇博客将会绘图展现方法内部字节码执行过程. 话不多说,贴上我们将要分析的Java方法 ...

  6. 【英语学习】2016.09.11 Culture Insider: Teacher's Day in ancient China

      Culture Insider: Teacher's Day in ancient China 2016-09-10 CHINADAILY Today is the 32nd Chinese Te ...

  7. JavaScript高阶函数

    所谓高阶函数(higher-order function) 就是操作函数的函数,它接收一个或多个函数作为参数,并返回一个新函数. 下面的例子接收两个函数f()和g(),并返回一个新的函数用以计算f(g ...

  8. 【webapp的优化整理】要做移动前端优化的朋友进来看看吧

    单页or多页 本文仅代表个人观点,不足请见谅,欢迎赐教. webapp 小钗从事单页相关的开发一年有余,期间无比的推崇webapp的网站模式,也整理了很多移动开发的知识点,但是现在回过头来看,weba ...

  9. 深入理解Javascript中构造函数和原型对象的区别

    在 Javascript中prototype属性的详解 这篇文章中,详细介绍了构造函数的缺点以及原型(prototype),原型链(prototype chain),构造函数(constructor) ...

  10. js自建方法库(持续更新)

    1.得到一个数,在一个有序数组中应该排在的位置序号: function orderInArr(num,arr) { if(num > arr[0]){ return 1 + arguments. ...