如何从特定行启动shell脚本?

RAF*_*FIQ 3 linux shell

#!/bin/sh
echo "install 1"
echo "install 2"
[ $? -eq 0 ] || exit $?;
cyberciti 
[ $? -eq 0 ] || exit $?;
echo "install 3"
echo "install 4"
Run Code Online (Sandbox Code Playgroud)

上面的脚本在第4行(cyberciti)处失败.在进行必要的更正后,如何跳过已经执行的命令,如何获取行号,并从该行开始重新运行脚本?

Bar*_*row 9

要跳过前4行(因此从第5行开始):

tail --lines=+5 script.sh | sh
Run Code Online (Sandbox Code Playgroud)

根据手册页,--lines=K意思是output the last K lines, instead of the last 10; or use -n +K to output starting with the Kth.

幸得亚伦Digulla他的回答在这里.编辑:感谢l0b0防止我cat接管世界!