basename和dirname的用法

#!/bin/bash
a="/home/fredric/daily/journal.txt"
echo "basename of /home/fredric/daily/journal.txt = `basename $a`"
echo "dirname of /home/fredric/daily/journal.txt = `dirname $a`"
echo
echo "My own home is `basename ~/`"
echo "The home of my home is `dirname ~/`"

程序输出如下,


1.png

你可能感兴趣的:(basename和dirname的用法)