Bash script absolute path with OS X

后端 未结 15 991
误落风尘
误落风尘 2020-11-29 18:20

I am trying to obtain the absolute path to the currently running script on OS X.

I saw many replies going for readlink -f $0. However since OS X\'s

15条回答
  •  -上瘾入骨i
    2020-11-29 18:44

    Use Python to get it:

    #!/usr/bin/env python
    import os
    import sys
    
    print(os.path.realpath(sys.argv[1]))
    

提交回复
热议问题