bash:传递参数但从 stdin 读取脚本
你可以使用 /dev/stdin 从 stdin 读取 bash 脚本,但仍传递命令行参数:
bash_pass_arguments_stdin_example.sh
cat myscript.sh | bash /dev/stdin arg1 arg2 # ...这在直接从 wget 或 curl 管道脚本时特别有用。示例:
bash_pass_arguments_stdin_example.sh
wget https://example.com/script.sh | bash /dev/stdin argCheck out similar posts by category:
Shell
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow