gpt4 book ai didi

Linux命令/脚本替换文件夹/目录

转载 作者:太空宇宙 更新时间:2023-11-04 09:20:37 25 4
gpt4 key购买 nike

我在 ubuntu 机器上设置了以下文件夹:
(括号表示文件夹)

[main]
|
|--- [old]
| |
| |--- [thequick]
| | |
| | |--- [aaaa] --- some files
| | |--- [bbbb] --- some files
| | |--- [cccc] --- some files
| | |--- [dddd] --- some files
| | |--- some files
| |
| |--- [brownfox]
| | |
| | |--- [aaaa] --- some files
| | |--- [bbbb] --- some files
| | |--- [cccc] --- some files
| | |--- [dddd] --- some files
| | |--- some files
| |--- ...
| |
| |--- [lazydog]
| |
| |--- [aaaa] --- some files
| |--- [bbbb] --- some files
| |--- [cccc] --- some files
| |--- [dddd] --- some files
| |--- some files
|
|--- [new]
|
|--- [thequick]
| |
| |--- [aaaa] --- some files
| |--- [bbbb] --- some files
| |--- some files
|
|--- [brownfox]
| |
| |--- [aaaa] --- some files
| |--- [bbbb] --- some files
| |--- some files
|--- ...
|
|--- [lazydog]
|
|--- [aaaa] --- some files
|--- [bbbb] --- some files
|--- some files

我需要找到一种快速的方法来将所有 [aaaa] 和[bbbb] 文件夹替换为它们各自的 [aaaa] 和[bbbb] 文件夹,< strong>不影响任何其他旧东西。

最佳答案

你可以这样做:

cd /main/old
find . -type d \( -name 'aaaa' -o -name '-bbbb' \) -exec cp -RfP {} ../new/{} \;

关于Linux命令/脚本替换文件夹/目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42342610/

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