bash-pattern

2013-06-14

bash pattern匹配

1 ${var%PATTERN}: Remove the Shortest Match from the End

$ var=Toronto
$ var=${var%o*}
$ printf “%s\n” “$var”Toront

2 File=vim-7.3.tar.bz2
echo ${FILE%.tar*}

3 ${#var}: Length of Variable’s Contents

4 ${var%%PATTERN}: Remove the Longest Match from the End
5 ${var#PATTERN}: Remove the Shortest Match from the Beginning
6 ${var##PATTERN}: Remove the Longest Match from the Beginning

7 ${var##PATTERN}: Remove the Longest Match from the Beginning
8 ${var//PATTERN/STRING}: Replace All Instances of PATTERN with STRING
9 ${var:OFFSET:LENGTH}: Return a Substring of $var
10 ${var%PATTERN}: Remove the Shortest Match from the End
11. ${var:OFFSET:LENGTH}: Return a Substring of $var

reference:
Pro Bash Programing Scripting GUN/Linux shell
http://blog.csdn.net/wesleyluo/article/details/5286606

分类:Linux编程 | 标签: |

相关日志

评论被关闭!