Denys Vlasenko | e3354bc | 2016-10-02 18:08:04 +0200 | [diff] [blame] | 1 | unset var |
| 2 | |
| 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%%*} |
| 11 | |
| 12 | var= |
| 13 | |
| 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%%*} |
| 22 | |
Denis Vlasenko | 033424a | 2008-04-12 22:55:33 +0000 | [diff] [blame] | 23 | var=ababcdcd |
| 24 | |
| 25 | echo ${var#ab} |
Denis Vlasenko | 033424a | 2008-04-12 22:55:33 +0000 | [diff] [blame] | 26 | echo ${var##ab} |
Denis Vlasenko | f78a656 | 2008-04-12 23:02:43 +0000 | [diff] [blame] | 27 | echo ${var#a*b} |
Denis Vlasenko | 033424a | 2008-04-12 22:55:33 +0000 | [diff] [blame] | 28 | echo ${var##a*b} |
| 29 | echo ${var#?} |
Denis Vlasenko | f78a656 | 2008-04-12 23:02:43 +0000 | [diff] [blame] | 30 | echo ${var##?} |
| 31 | echo ${var#*} |
Denys Vlasenko | e3354bc | 2016-10-02 18:08:04 +0200 | [diff] [blame] | 32 | echo Empty:${var##*} |
| 33 | echo ${var#}}_tail |
| 34 | echo ${var#\}}_tail |
Denis Vlasenko | 033424a | 2008-04-12 22:55:33 +0000 | [diff] [blame] | 35 | |
| 36 | echo ${var%cd} |
Denis Vlasenko | 033424a | 2008-04-12 22:55:33 +0000 | [diff] [blame] | 37 | echo ${var%%cd} |
Denis Vlasenko | f78a656 | 2008-04-12 23:02:43 +0000 | [diff] [blame] | 38 | echo ${var%c*d} |
Denis Vlasenko | 033424a | 2008-04-12 22:55:33 +0000 | [diff] [blame] | 39 | echo ${var%%c*d} |
| 40 | echo ${var%?} |
Denis Vlasenko | f78a656 | 2008-04-12 23:02:43 +0000 | [diff] [blame] | 41 | echo ${var%%?} |
| 42 | echo ${var%*} |
Denys Vlasenko | e3354bc | 2016-10-02 18:08:04 +0200 | [diff] [blame] | 43 | echo Empty:${var%%*} |
| 44 | echo ${var#}}_tail |
| 45 | echo ${var#\}}_tail |
| 46 | echo ${var%\\*} |
Denis Vlasenko | f78a656 | 2008-04-12 23:02:43 +0000 | [diff] [blame] | 47 | |
Denys Vlasenko | e3354bc | 2016-10-02 18:08:04 +0200 | [diff] [blame] | 48 | a=ab}; echo ${a%\}}; |
| 49 | a=abc; c=c; echo ${a%${c}} |
| 50 | a=ab{{c; echo ${a%`echo {{c`} |
| 51 | |
| 52 | echo End |