英文:
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
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论