bash: Pass arguments but read script from stdin
You can use /dev/stdin to read the bash script from stdin but still pass command line arguments:
bash_pass_arguments_stdin_example.sh
cat myscript.sh | bash /dev/stdin arg1 arg2 # ...This is especially useful when directly piping scripts from wget or curl. Example:
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