{A,B} 在 shell 中是什么意思?

rob*_*rre 2 shell brace-expansion

我正在阅读这个文件,一个flatpak应用程序的清单。

有以下命令:

ln -s /app/{extra,bin}/masterpdfeditor5
Run Code Online (Sandbox Code Playgroud)

什么{extra,bin}意思?

Pou*_*rko 12

支撑扩展:https : //www.gnu.org/software/bash/manual/html_node/Brace-Expansion.html

在您的特定示例中,shell 会将大括号扩展扩展/app/{extra,bin}/masterpdfeditor5为两个字符串/app/extra/masterpdfeditor5/app/bin/masterpdfeditor5(按此顺序)。该ln -s命令将接收这两个字符串作为参数,因此它将创建一个名为/app/bin/masterpdfeditor5指向的软链接/app/extra/masterpdfeditor5

  • 请允许我补充一点,人们认为通配符和其他扩展语法是由命令处理的,例如由`ln`。请注意,处理这些字符的是外壳程序,而不是命令,这一点非常重要。该命令获取 shell 处理的结果。有例外;例如,`find` 在某些上下文中会处理通配符。 (3认同)