self-exec.sh
来自「BASH Shell 编程 经典教程 《高级SHELL脚本编程》中文版」· Shell 代码 · 共 20 行
SH
20 行
#!/bin/bash# self-exec.shechoecho "This line appears ONCE in the script, yet it keeps echoing."echo "The PID of this instance of the script is still $$."# 上边这行展示了并没有fork出子shell.echo "==================== Hit Ctl-C to exit ===================="sleep 1exec $0 # 产生了本脚本的另一个实例, #+ 但是这个新产生的实例却代替了原来的实例.echo "This line will never echo!" # 为什么不是这样?exit 0
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?