dirname
dirname
strip last component from file name (strip 除去,剥去) 把文件的绝对路径的最后一个除去 如:
dirname /usr/bin/ -> "/usr"
eric@eric-virtual-machine:~/ethdev1$ dirname /home/eric/ /root/ /opt
/home
/
/
eg: dirname $0
返回当前执行脚本的目录
eric@eric-virtual-machine:~$ cat ethdev1/test.sh #!/bin/bash cd `dirname $0` echo `pwd` eric@eric-virtual-machine:~$ ethdev1/test.sh /home/eric/ethdev1 eric@eric-virtual-machine:~$ pwd /home/eric eric@eric-virtual-machine:~$
We only live once, and time just goes by.