self-exec.sh
来自「Shall高级编程」· Shell 代码 · 共 21 行
SH
21 行
#!/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 $$."# Demonstrates that a subshell is not forked off.echo "==================== Hit Ctl-C to exit ===================="sleep 1exec $0 # Spawns another instance of this same script #+ that replaces the previous one.echo "This line will never echo!" # Why not?exit 99 # Will not exit here! # Exit code will not be 99!
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?