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:

cat myscript.sh | bash /dev/stdin arg1 arg2 # ...

This is especially useful when directly piping scripts fromĀ wget or curl. Example:

wget https://example.com/script.sh | bash /dev/stdin arg