We could execute command into bash in different form from stdin, file and web request.
read from file
1
2
3
4
5
|
bash file-script.sh
# or
sh file-script.sh
# or
source file-script.sh
|
read from file with parameter
1
2
3
4
5
|
bash file-script.sh {param}
# or
sh file-script.sh {param}
# or
source file-script.sh {param}
|
pass through pipeline
1
2
3
4
5
|
cat file-script.sh | bash
# or
cat file-script.sh | sh
# source doesn't support pipeline
|
pass through process subsitution
1
2
3
4
5
|
bash <(cat file-script.sh)
# or
sh <(cat file-script.sh)
# or
source <(ca file-script.sh)
|
pass through process subsitution with parameter
1
2
3
4
5
|
bash <(cat file-script.sh) {parameter}
# or
sh <(cat file-script.sh) {parameter}
# or
source <(ca file-script.sh) {parameter}
|
We could also pull a shell script from web request.
1
2
3
4
5
|
bash <(curl {url})
# or
sh <(curl {url})
# or
source <(curl {url})
|