the*_*tar 2 linux bash shell command-line
在 中bash,假设我想链接目录中的一些但不是所有文件,例如,
ln -s /dir/file1 /dir/file2 ... /other/dir
Run Code Online (Sandbox Code Playgroud)
但是文件名的格式不遵循一些简单的规则,所以我们不能使用类似
ln -s /dir/file* /target/dir.
Run Code Online (Sandbox Code Playgroud)
无论如何不要重复/dir,例如:
/dir/{file1 file2 ...} = /dir/file1 /dir/file2 ...
Run Code Online (Sandbox Code Playgroud)
所以我们可以做这样的事情:
ln -s /dir/{file1 file2 ...} /target/dir
Run Code Online (Sandbox Code Playgroud)
是的,语法与您想要做的非常相似。说:
ln -s /dir/{file1,file2,foo,bar} /target/dir
Run Code Online (Sandbox Code Playgroud)
将文件file1, file2, foo,bar从/dir/到/target/dir/.
上述语法称为大括号扩展。
(大括号扩展导致/dir/{file1,file2,foo,bar}扩展到/dir/file1 /dir/file2 /dir/foo /dir/bar.)
| 归档时间: |
|
| 查看次数: |
247 次 |
| 最近记录: |