【转载】利用shell脚本获取一个文件的绝对路径readlink
转载自:http://os.chinaunix.net/a2007/1118/976/000000976787.shtml
#! /bin/bash echo "Path to $(basename $0) is $(readlink -f $0)"
可以看一下执行结果:
pengdl@localhost:~/test/shell$ ls
sh1.sh
pengdl@localhost:~/test/shell$ ./sh1.sh
Path to sh1.sh is /home/pengdl/test/shell/sh1.sh
pengdl@localhost:~/test/shell$
本文来自博客园,作者:摩斯电码,未经同意,禁止转载