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