We often encounter this problem when using Linux. for example, execute the command $ cpetcaptsourceslistetcaptsourceslistbak here.
We often encounter such a problem when using Linux, for example, executing a command
$ Cp/etc/apt/sources. list/etc/apt/sources. list. bak
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, it will take a lot of effort. it is similar to the above example: back up a file and rename a file, or to create a link, perform similar operations and repeat the same path. it is generally wise to first cd to that directory and then perform operations under that directory, after the cd is complete, it will be difficult 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 be disconnected, 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 the interpretation, and then becomes the same complete command as the above, thus achieving the operation without leaving the house, the previous directory strings only need to be typed once, and 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 is used to represent the blank. 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.