How to get full path of a file?

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

    In a similar scenario, I'm launching a cshell script from some other location. For setting the correct absolute path of the script so that it runs in the designated directory only, I'm using the following code:

    set script_dir = `pwd`/`dirname $0`
    

    $0 stores the exact string how the script was executed.

    For e.g. if the script was launched like this: $> ../../test/test.csh, $script_dir will contain /home/abc/sandbox/v1/../../test

提交回复
热议问题