问题描述
在目录里面
~/domains/annejulie.blue-world.pl/git
我想获取除 annejulie.blue-world.pl.git 目录之外的所有文件和目录,并将它们移动到该目录中 (annejulie.blue-world.pl.git强>)
i want to get all files and directories excluding annejulie.blue-world.pl.git directory and move them into that directory (annejulie.blue-world.pl.git)
如何在终端中使用 find 和 grep 命令执行此操作?有可能吗?
How to do this in terminal with find and grep command? is it possible?
推荐答案
首先在终端中执行以下命令.这扩展了正则表达式.
Execute the following command first in terminal. This extends regexes.
shopt -s extglob
现在可以执行下面的 mv 命令了
Now you can execute the following mv command
mv !(<file/dir not to be moved>) <Path to dest>
例如,如果您在 ~/Test 并且需要将除 ~/Test/Dest 以外的所有内容移动到 ~/Test/Dest,则可以如下执行它,假设您位于 ~/Test
For example, If you are at ~/Test and you need to move all except ~/Test/Dest to ~/Test/Dest, you can execute it as given below, assuming you are at ~/Test
mv !(Dest) ~/Test/Dest
这篇关于如何将不包括特定目录的文件和目录移动到此目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!