shell 根据文件路径获取文件名的函数

全栈 shanhuhai 2135℃

!/bin/bash

function get_repos_name
{
     line=$1
     arr=(${line//\// })
     line=${arr[1]}
     arr=(${line//./ })
     echo ${arr[0]}

}
line="/repos/xxx.git"
repos_name=$(get_repos_name $line)
echo $repos_name

转载请注明:大后端 » shell 根据文件路径获取文件名的函数

付费咨询
喜欢 (0)or分享 (0)