Often see commands like the following in blogs or forums the curly braces extend brace expansion {} Shell functions
Cp/etc/httpd/httpd. {,. Bakup}
Or is
So what does it mean in the uinx/linux shell command?
{} has no practical meaning, but can be used as a brace expansion (curly braces extension or curly braces extension) to produce various groups. Here's what's translated from the Gnu/bash man page:
Brace expansion (curly brace extension or curly braces extension) is a mechanism for randomly generating string combinations. This mechanism is similar to the file extension, but does not require a response file. The brace expansion (curly brace extension or curly brace extension) pattern is an optional preamble (leading character) followed by a series of comma-delimited strings, enclosed in a pair of curly braces, followed by an optional PostScript (print programming language). Preamble (leading characters) are added before each string in curly braces, and PostScript (the Print programming language) is appended to each result string, extending from left to right. Curly brace extensions can be nested. The results of the extended string are not sorted; instead, the left to right order is preserved.
1. For example, enter the following command in the terminal:
The output is as follows:
Foo1.txt Foo2.txt Foo3.txt
2. You can also use the attached example below to "create" a parameter in the command to save time for input and increase productivity:
Echo File.txt{,.bak}
Echo File-{a. D}.txt
echo mkdir-p/apache-jail/{usr,bin,lib64,dev}
echo CP httpd.conf{,.backup}
echo MV delta.{ Txt,doc}
3. You can use the brace expansion (curly braces extension or curly braces extension) to copy, rename, or back up files, or create a directory. In the following habitual use example, the File1.txt is backed up as File2.txt.bak and entered:
CP- v file1.txt file1.txt.bak
If you use brace expansion to save time, enter:
The output is as follows:
File1.txt-> File1.txt.bak
More curly braces extension examples are as follows:
4. If we implement:
$ cp/etc/apt/sources.list /etc/apt/sources.list.bak
These two/etc/apt/sources parts are the same, in order to enter two times less/etc/apt/sources, brace extension parameters. It is also possible to use curly braces to extend the parameters of the normal renaming, backing up files, and creating links to improve efficiency.
Curly braces extend, which is surrounded by braces, and arguments separated by commas extend to multiple independent arguments.
$ cp/etc/apt/sources. {List,list.bak}
The Shell, when interpreted, automatically expands the following arguments to two, and becomes the complete command as above.
Of course, it can be simpler to take the list into account and write nothing before the comma, as follows:
$ Cp/etc/apt/sources.list{,.bak}
So there is nothing in front of the comma, then the parameters will remain the same, the comma after the extension.