If you use @fedorqui's resource, you'll see it is going to strip the shortest match of /*
from the end of the first positional argument. An example:
example_foo(){
echo ${1%/*}
}
example_foo path/to/directory/sub_directory
# => path/to/directory
In the example I used the second positional argument since the first is the name of the function.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…