这是什么时候在bash命令运行分号吗? [英] What does the semicolon do when it is run in a bash command?

查看:144
本文介绍了这是什么时候在bash命令运行分号吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如,运行时,

echo a; echo b

在终端,它的输出是:

in the terminal, its output is:

a
b

在我看来,对于第一个命令分号等待(回声)来完成,然后开始第二个命令(回声b )。

It seems to me that the semicolon waits for the first command (echo a) to finish, then it starts the second command (echo b).

问:只是用于在bash遍历命令分号

Q: Is the semicolon just used for iterating over commands in bash?

问:什么时候在bash命令运行分号做

Q: What does the semicolon do when it is run in a bash command?

推荐答案

; 分隔两个命令

echo a; echo b

这让庆典知道回声回声b 是两个独立的命令,需要单独运行一前一后

It lets the bash know that echo a and echo b are two separate commands and need to be run separately one after the other

尝试没有分号

$ echo a echo b
a echo b

下面的语句作为单个命令回声 A回声b 作为参数传递给回声

Here the statement is taken as a single command echo and a echo b is passed as parameter to the echo

这篇关于这是什么时候在bash命令运行分号吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆