Multiple running bash script 1 command line?

huangapple go评论52阅读模式
英文:

Multiple running bash script 1 command line?

问题

如何在一个 bash 命令中运行多个 bash 脚本?

我使用的命令是

bash script1.sh

如何使其在一个命令中运行多个脚本?

例如

bash script1.sh bash script2.sh bash script3.sh bash script4.sh

请帮忙

英文:

how to run multiple bash scripts in 1 bash command ?

i use command

> bash script1.sh

how to make it run multiple commands in 1 command ?

for example

bash script1.sh bash script2.sh bash script3.sh bash script4.sh

Please help

答案1

得分: 0

If you want to run all bash script in //:

for i in {1..4}; do bash "script${i}.sh" & done

If you put the control operator & at the end of a command, e.g. command &, the shell executes the command in the background in a subshell. The shell does not wait for the command to finish, and the return status is 0. Pid of the last backgrounded command is available via the special variable $!


If instead you want to run sequentially, use

printf '%s\n' script{1..4}.sh | xargs -n1 bash

or

for i in {1..4}; do bash "script${i}.sh"; done
英文:

If you want to run all bash script in //:

for i in {1..4}; do bash "script${i}.sh" & done

If you put the control operator & at the end of a command, e.g. command &, the shell executes the command in the background in a subshell. The shell does not wait for the command to finish, and the return status is 0. Pid of the last backgrounded command is available via the special variable $!


If instead you want to run sequentially, use

printf '%s\n' script{1..4}.sh | xargs -n1 bash

or

for i in {1..4}; do bash "script${i}.sh"; done

huangapple
  • 本文由 发表于 2023年2月18日 17:39:55
  • 转载请务必保留本文链接:https://go.coder-hub.com/75492444.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定