Mike Frysinger | e05f928 | 2009-04-09 23:01:47 +0000 | [diff] [blame] | 1 | unset var |
| 2 | |
Denis Vlasenko | 75bccfa | 2009-04-10 23:48:03 +0000 | [diff] [blame] | 3 | echo Empty:${var#} |
| 4 | echo Empty:${var##} |
| 5 | echo Empty:${var#*} |
| 6 | echo Empty:${var##*} |
| 7 | echo Empty:${var%} |
| 8 | echo Empty:${var%%} |
| 9 | echo Empty:${var%*} |
| 10 | echo Empty:${var%%*} |
Mike Frysinger | e05f928 | 2009-04-09 23:01:47 +0000 | [diff] [blame] | 11 | |
| 12 | var= |
| 13 | |
Denis Vlasenko | 75bccfa | 2009-04-10 23:48:03 +0000 | [diff] [blame] | 14 | echo Empty:${var#} |
| 15 | echo Empty:${var##} |
| 16 | echo Empty:${var#*} |
| 17 | echo Empty:${var##*} |
| 18 | echo Empty:${var%} |
| 19 | echo Empty:${var%%} |
| 20 | echo Empty:${var%*} |
| 21 | echo Empty:${var%%*} |
Mike Frysinger | e05f928 | 2009-04-09 23:01:47 +0000 | [diff] [blame] | 22 | |
Mike Frysinger | a4f331d | 2009-04-07 06:03:22 +0000 | [diff] [blame] | 23 | var=ababcdcd |
| 24 | |
| 25 | echo ${var#ab} |
| 26 | echo ${var##ab} |
| 27 | echo ${var#a*b} |
| 28 | echo ${var##a*b} |
| 29 | echo ${var#?} |
| 30 | echo ${var##?} |
| 31 | echo ${var#*} |
Denis Vlasenko | 75bccfa | 2009-04-10 23:48:03 +0000 | [diff] [blame] | 32 | echo Empty:${var##*} |
Denis Vlasenko | bf25fbc | 2009-04-19 13:57:51 +0000 | [diff] [blame] | 33 | echo ${var#}}_tail |
Denys Vlasenko | 7436950 | 2010-05-21 19:52:01 +0200 | [diff] [blame] | 34 | echo ${var#\}}_tail |
Mike Frysinger | a4f331d | 2009-04-07 06:03:22 +0000 | [diff] [blame] | 35 | |
| 36 | echo ${var%cd} |
| 37 | echo ${var%%cd} |
| 38 | echo ${var%c*d} |
| 39 | echo ${var%%c*d} |
| 40 | echo ${var%?} |
| 41 | echo ${var%%?} |
| 42 | echo ${var%*} |
Denis Vlasenko | 75bccfa | 2009-04-10 23:48:03 +0000 | [diff] [blame] | 43 | echo Empty:${var%%*} |
Denis Vlasenko | bf25fbc | 2009-04-19 13:57:51 +0000 | [diff] [blame] | 44 | echo ${var#}}_tail |
Denys Vlasenko | 7436950 | 2010-05-21 19:52:01 +0200 | [diff] [blame] | 45 | echo ${var#\}}_tail |
Denis Vlasenko | 5b7589e | 2009-04-26 11:25:19 +0000 | [diff] [blame] | 46 | echo ${var%\\*} |
Mike Frysinger | a4f331d | 2009-04-07 06:03:22 +0000 | [diff] [blame] | 47 | |
Denys Vlasenko | 7436950 | 2010-05-21 19:52:01 +0200 | [diff] [blame] | 48 | a=ab}; echo ${a%\}}; |
| 49 | a=abc; c=c; echo ${a%${c}} |
Denys Vlasenko | a6ad397 | 2010-05-22 00:26:06 +0200 | [diff] [blame] | 50 | a=ab{{c; echo ${a%`echo {{c`} |
Denys Vlasenko | 7436950 | 2010-05-21 19:52:01 +0200 | [diff] [blame] | 51 | |
| 52 | echo End |