见:https://zhidao.baidu.com/question/348625350.html
---------------------------------------------------------------------------------------------
bruce@bruce-Lenovo-IdeaPad-V450:~$ i="abc,def,ghi,jlk"
bruce@bruce-Lenovo-IdeaPad-V450:~$ echo ${i%%,*}abc
bruce@bruce-Lenovo-IdeaPad-V450:~$ echo ${i%,*}
abc,def,ghi
bruce@bruce-Lenovo-IdeaPad-V450:~$ echo ${i##*,}
jlk
bruce@bruce-Lenovo-IdeaPad-V450:~$ echo ${i#*,}
def,ghi,jlk
bruce@bruce-Lenovo-IdeaPad-V450:~$
本文通过一个具体的Shell脚本示例展示了如何使用Shell内置的字符串截取功能来处理以逗号分隔的数据。该示例包括去除字符串前缀、去除后缀、删除首个指定字符后的所有内容以及移除首个特定字符前的所有字符等操作。
853

被折叠的 条评论
为什么被折叠?



