linux 中%.*、%%.*的意义

 

1、举例%.*的作用

root@DESKTOP-1N42TVH:/home/test3# a="aa.bb.cc.dd"
root@DESKTOP-1N42TVH:/home/test3# echo ${a}
aa.bb.cc.dd
root@DESKTOP-1N42TVH:/home/test3# echo ${a%.*}    ## %.*的作用是删除变量最后一个.及其后的内容
aa.bb.cc

 

root@DESKTOP-1N42TVH:/home/test3# a="2e.@#.%34.3#@$"
root@DESKTOP-1N42TVH:/home/test3# echo ${a}
2e.@#.%34.3#@$
root@DESKTOP-1N42TVH:/home/test3# echo ${a%.*}    ## %.*的作用是删除变量最有一个.及其后的内容。
2e.@#.%34

 

2、举例:%%.*的作用

root@DESKTOP-1N42TVH:/home/test3# a="aa.bb.cc.dd"
root@DESKTOP-1N42TVH:/home/test3# echo ${a}
aa.bb.cc.dd
root@DESKTOP-1N42TVH:/home/test3# echo ${a%%.*}   ## %%.*的作用是删除变量第一个.及其后的内容
aa

 

参考:https://blog.csdn.net/qq_30130417/article/details/80911989

 

posted @ 2022-04-29 22:43  小鲨鱼2018  阅读(3054)  评论(0编辑  收藏  举报