Command Line tips-extended parameters using braces-general Linux technology-Linux programming and kernel information. For more information, see the following. This scenario:
$ Cp/etc/apt/sources. list/etc/apt/sources. list. bak
We often encounter that similar operations are required to back up a file, rename a file, or create a link. There is a problem here. The words/etc/apt/sources are the same. Why do I need to repeat them twice? This is a little short. If the directory is deeper, the effort will be great. It is usually wise to first cd to that directory, then operate under that directory, and then cd back. But it is still troublesome to do so. Is there any solution without leaving the house? The answer is yes.
Bash has a function called braces extension. parameters enclosed by braces, separated by commas, are extended to multiple independent parameters. In this case, you must have deleted the file. Specifically, the example of the backup file above can be written:
$ Cp/etc/apt/sources. {list, list. bak}
Shell automatically expands the following parameters into two during interpretation, and then becomes the same complete command as above. In this way, the operation is performed without leaving the house, and the previous list of directories only needs to be typed once, and even the cd is skipped.
In fact, this command can be simplified, and the list can also be used in the past. I have been thinking about what to use to represent the blank space. In fact, nothing needs to be written.
$ Cp/etc/apt/sources. list {,. bak}
In this way, there is nothing before the comma, so the parameter remains unchanged, and the extension after the comma remains unchanged.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.