Skip to content

Commit 1955d80

Browse files
committed
Add the "Bash: Brace expansion" page.
1 parent 0418536 commit 1955d80

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

content/notes/Bash.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@ Bash is an interactive command interpreter and command programming language deve
66

77
Subpages:
88

9+
- [Brace expansion](@/notes/Bash_Brace_expansion.md)
910
- [Parameter expansion](@/notes/Bash_Parameter_expansion.md)
1011
- [Positional parameters](@/notes/Bash_Positional_parameters.md)
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
+++
2+
title = "Bash: Brace expansion"
3+
+++
4+
5+
In Bash, brace expansion is a mechanism by which arbitrary strings may be generated.
6+
7+
It has two forms:
8+
9+
1. Comma-separated strings.
10+
11+
For example, `a{d,c,b}e` expands to `ade ace abe`.
12+
13+
2. Sequence expression.
14+
15+
For example,
16+
17+
- `S{1..4}` expands to `S1 S2 S3 S4`;
18+
- `{0..4..2}` expands to `0 2 4`;
19+
- `{a..f}` expands to `a b c d e f`.
20+
21+
Brace expansions can be combined. For example, `{a..b}{1..2}` expands to `a1 a2 b1 b2`.
22+
23+
Brace expansions tend to be most useful when dealing with file paths (especially if the paths are long and some of the files don't exist yet). For example, `mv /long/path/to/file_{old,new}`.
24+
25+
See [`man bash`](https://www.man7.org/linux/man-pages/man1/bash.1.html) for more information.
26+
27+
## See also
28+
29+
- [Bash](@/notes/Bash.md)

0 commit comments

Comments
 (0)