linux中奇怪的语法(持续更新)

%/和#/

#!/bin/sh

files=`find -name *.conifg`

for i in $files
do
  name=${
    
    i#*/}
  dir=${
    
    name%/*}
done

i=this/is/a/path.config
name=is/a/path.config
dir=this/is/a

# ${string#substring}Strip shortest match of $substring from front of $string
# ${string%substring}Strip shortest match of $substring from back of $string
# #代表删除从前往后最小匹配的内容
# %代表删除从后往前最小匹配的内容

猜你喜欢

转载自blog.csdn.net/qq_28686911/article/details/113945096
今日推荐