How to get full path of a file?

后端 未结 30 3235
走了就别回头了
走了就别回头了 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:47

    Create a function like the below (echoes the absolute path of a file with pwd and adds the file at the end of the path:

    abspath() { echo $(pwd "$1")/"$1"; }
    

    Now you can just find any file path:

    abspath myfile.ext
    

提交回复
热议问题