gpt4 book ai didi

Linux 在循环中将文件从基本路径移动到多个路径

转载 作者:太空宇宙 更新时间:2023-11-04 06:06:14 24 4
gpt4 key购买 nike

您能否提供一些指示,以有效的方式将文件从基本路径移动到多个路径。文件夹结构已创建。

/Path/AdminUser/User1/1111/Reports/aaa.txt 到/Path/User1/1111/Reports/aaa.txt
/Path/AdminUser/User1/2222/Reports/bbb.txt 到/Path/User1/2222/Reports/bbb.txt
/Path/AdminUser/User2/3333/Reports/ccc.txt 到/Path/User2/3333/Reports/ccc.txt
/Path/AdminUser/User2/3333/Reports/ddd.txt 到/Path/User2/3333/Reports/ddd.txt

我不想移动目录结构。我想每天将文件从源路径移动到目标路径。我需要指针来编写 bash 脚本,以确保 aaa.txt 准确地从 /Path/AdminUser/User1/1111/Reports//Path/User1/1111/Reports/........

例如:

#!/bin/bash

dir1="/Path"
subs= `ls $dir1/AdminUser`
for i in $subs; do
mv $dir1/AdminUser/$i/*/Reports $dir1/$i/*/Reports
done

最佳答案

这看起来不需要脚本就可以实现。看看 rsync。

rsync -r /Path/AdminUser/* /NewPath/

关于Linux 在循环中将文件从基本路径移动到多个路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30010248/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com