Can I get the absolute path to the current script in KornShell?

前端 未结 12 574
粉色の甜心
粉色の甜心 2020-12-29 06:26

Is it possible to find out the full path to the script that is currently executing in KornShell (ksh)?

i.e. if my script is in /opt/scripts/myscript.ksh

12条回答
  •  别那么骄傲
    2020-12-29 06:52

    Using $_ provides the last command.

    >source my_script
    

    Works if I issue the command twice:

    >source my_script
    >source my_script
    

    If I use a different sequence of commands:

    >who
    >source my_script
    

    The $_ variable returns "who"

提交回复
热议问题