Hi,
coreutils can give abspaths ('readlink -f -e'). But I'm not able to
find a command for relative paths. I use the following python script
to do so. The drawback is that it is dependent on python (meaning it
is less portable). But I'm wondering if it is possible to add such a
command (or an option of a command) in coreutils.
~$ cat `which relpath.py `
#!/usr/bin/env python
import sys
import os
args = sys.argv
if len(args)-1 != 1 and len(args)-1 != 2:
print >> sys.stderr, "Usage: %s <path> " %(os.path.basename(args[0]))
print >> sys.stderr, "Usage: %s <path> <start>" %(os.path.basename(args[0]))
sys.exit()
if len(args)-1 == 1:
start='.'
else:
start=args[2]
path=args[1]
print os.path.relpath(path, start)
--
Regards,
Peng