!/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 根据文件路径获取文件名的函数