Shell #*/ 和 %/* #!/bin/bash i="this/is/a/path.config" name=${i#*/} path=${i%/*} echo $name echo $path is/a/path.config this/is/a