How to get full path of a file?

后端 未结 30 3277
走了就别回头了
走了就别回头了 2020-12-02 03:22

Is there an easy way I can print the full path of file.txt ?

file.txt = /nfs/an/disks/jj/home/dir/file.txt

The

30条回答
  •  一向
    一向 (楼主)
    2020-12-02 03:50

    I know there's an easier way that this, but darned if I can find it...

    jcomeau@intrepid:~$ python -c 'import os; print(os.path.abspath("cat.wav"))'
    /home/jcomeau/cat.wav
    

    jcomeau@intrepid:~$ ls $PWD/cat.wav
    /home/jcomeau/cat.wav
    

提交回复
热议问题