如何将不包含一个特定目录的文件和目录移动到此目录 [英] How to move files and directories excluding one specific directory to this directory

查看:92
本文介绍了如何将不包含一个特定目录的文件和目录移动到此目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



里面目录

 〜/ domains / annejulie.blue-world.pl / git 

我想要获取除 annejulie.blue-world.pl.git 目录之外的所有文件和目录,并将它们移动到该目录中 find > grep 命令?是否有可能?

解决方案

在终端中首先执行以下命令。这扩展了正则表达式。

  shopt -s extglob 

现在您可以执行以下mv命令:

  mv!(< file / dir不被移动>)<目的地的路径> 

例如,如果您在〜/ Test并且需要移动除〜/ Test / Dest to〜/ Test / Dest,假设你在〜/ Test $ / b
$ b

  mv!( Dest)〜/ Test / Dest 


inside the directory

~/domains/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)

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

Now you can execute the following mv command

mv !(<file/dir not to be moved>) <Path to dest>

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

这篇关于如何将不包含一个特定目录的文件和目录移动到此目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆