[英]How to move all files and folders into a subfolder of the same folder
in the gitlab-ci for our automatic deployment pipeline, we need to move all files and folders of the old application into a folder "_backup" in the same root directory.在我们的自动部署管道的 gitlab-ci 中,我们需要将旧应用程序的所有文件和文件夹移动到同一根目录中的文件夹“_backup”中。
This is our approach: mv /mnt/test.local/* /mnt/test.local/_backup
这是我们的方法: mv /mnt/test.local/* /mnt/test.local/_backup
But the error messages are: mv: can't rename '/mnt/test.local/favicon.ico': No such file or directory
但错误信息是: mv: can't rename '/mnt/test.local/favicon.ico': No such file or directory
I think the problem is that I can not move all files and folders (including "_backup"-folder) into the "_backup"-folder.我认为问题在于我无法将所有文件和文件夹(包括“_backup”文件夹)移动到“_backup”文件夹中。 I read about the extglob
shell options, but !(_backup)
is not working, is there another way?我阅读了有关extglob
shell 选项的信息,但是!(_backup)
不起作用,还有其他方法吗?
Update : I tried @Kent's approach, but somehow it is not working.更新:我尝试了@Kent 的方法,但不知何故它不起作用。 When I test it locally I get the following error but it works:当我在本地测试它时,我收到以下错误,但它可以工作:
$ find ~/Workspace/testingmove/ -mindepth 1 -maxdepth 1 -path ~/Workspace/testingmove/_backup -prune -o -print|xargs -I{} mv {} -t ~/Workspace/testingmove/_backup
mv: rename /Users/wiesenberg/Workspace/testingmove//_backup to /Users/wiesenberg/Workspace/testingmove/_backup/_backup: Invalid argument
mv: rename -t to /Users/wiesenberg/Workspace/testingmove/_backup/-t: No such file or directory
And when I try it in the gitlab-ci, the following error accurs:当我在 gitlab-ci 中尝试时,会出现以下错误:
$ find /mnt/test.local/ -mindepth 1 -maxdepth 1 -path /mnt/test.local/_backup -prune -o -print|xargs -I{} mv {} -t /mnt/test.local/_backup/
mv: unrecognized option: t
BusyBox v1.31.1 () multi-call binary.
Usage: mv [-fin] SOURCE DEST
or: mv [-fin] SOURCE... DIRECTORY
Thanks, Marc谢谢,马克
You can use find
to exclude the backup directory:您可以使用find
排除备份目录:
find /YourHome -mindepth 1 -path /YourHome/_backup -prune -o -print|xargs -I{} cp -r {} /YourHome/_backup
Replace the cp
command in xargs with mv
if you want to do "mv"如果要执行“ mv
”,请将 xargs 中的cp
命令替换为 mv
find /YourHome -mindepth 1 -maxdepth 1 -path /YourHome/_backup -prune -o -print|xargs -I{} mv {} -t /YourHome/_backup
My workaround is that I created a two subfolders and routed the Webserver to the subfolder.我的解决方法是创建了两个子文件夹并将 Web 服务器路由到子文件夹。
- root
- _backup
- website
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.