Linux command
brace 命令
文本
涉及管道、覆盖或删除,执行前请先确认路径和参数。
常用示例
Command grouping (current shell)
{ [command1]; [command2]; }
Brace expansion
echo {a,b,c}
Sequence expansion
echo {1..10}
Parameter expansion
echo ${var}
Create multiple files
touch file{1,2,3}.txt
说明
{ } (braces/curly brackets) serve multiple purposes in shell: Command grouping: { cmd1; cmd2; } groups commands to run in the current shell (unlike (...) which uses a subshell). Requires spaces after { and ; before }. Brace expansion: {a,b,c} expands to a b c. Useful for generating lists: - file{1,2,3} → file1 file2 file3 - {a..z} → alphabet - {1..10} → numbers 1-10 - {01..10} → zero-padded: 01 02 ... 10 Parameter expansion: ${var} accesses variables, required for: - Array access: ${array0} - Modifiers: ${var:-default} - Disambiguation: ${var}text
FAQ
What is the brace command used for?
{ } (braces/curly brackets) serve multiple purposes in shell: Command grouping: { cmd1; cmd2; } groups commands to run in the current shell (unlike (...) which uses a subshell). Requires spaces after { and ; before }. Brace expansion: {a,b,c} expands to a b c. Useful for generating lists: - file{1,2,3} → file1 file2 file3 - {a..z} → alphabet - {1..10} → numbers 1-10 - {01..10} → zero-padded: 01 02 ... 10 Parameter expansion: ${var} accesses variables, required for: - Array access: ${array0} - Modifiers: ${var:-default} - Disambiguation: ${var}text
How do I run a basic brace example?
Run `{ [command1]; [command2]; }` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
Where can I find more brace examples?
This page includes 5 examples for brace, plus related commands for nearby Linux tasks.