, 在 bash 中是什么意思?例如,“accurev update -9 2>,update 1>&2”中的 , 是什么意思?(accurev是一个版本控制软件)
抱歉这个蹩脚的问题,我只是不知道如何用谷歌搜索特殊字符。
Den*_*son 13
可以在大括号扩展中使用逗号,但您显示的示例中没有大括号。
此命令会将其输出存储在两个文件中,一个称为“def”,另一个称为“abcdef”:
echo hello | tee {,abc}def
Run Code Online (Sandbox Code Playgroud)
或“file1”和“file2”中的这个:
echo hello | tee file{1,2}
Run Code Online (Sandbox Code Playgroud)
逗号可用于分隔let语句或等效(())结构中算术运算中的命令:
let a=1,b=2 # no spaces permitted
(( a = 1 , b = 2 ))
(( ++c, --d, e+=4 ))
Run Code Online (Sandbox Code Playgroud)
您可以在for语句中使用逗号来处理除主索引之外的其他变量,而不是将变量操作放在for. 这样做可能是不好的编程习惯:
for ((i=1,j=4; i<4,j<7; i++,j+=2)); do echo $i $j; done
Run Code Online (Sandbox Code Playgroud)
逗号也可以在 Bash 4 中用于将字符串更改为小写(只显示了几个变体):
$ words="This is a TEST"
$ echo ${words,,} # the whole string is lowercased
this is a test
$ echo ${words,} # only the first character
this is a TEST
Run Code Online (Sandbox Code Playgroud)