How can I find the location of the tcsh shell script I'm executing?

后端 未结 4 1252
攒了一身酷
攒了一身酷 2021-02-20 05:10

Say I put an executable tcsh file in /path/to/my_script.csh

and my current directory is anywhere, for example I\'m in /path

So I type to/my_script.csh

I

4条回答
  •  眼角桃花
    2021-02-20 05:32

    In c shell, try like this:

    set rootdir = `dirname $0`
    set abs_rootdir = `cd $rootdir && pwd`
    echo $abs_rootdir
    

提交回复
热议问题