我有这样的目录结构;
dir
├── dirA
│ └── file1
│ └── subdir
└── dirB
└── file2
└── subdir
我需要将file1移至dirA / subdir,将file2移至dirB / subdir。我如何在Linux中做到这一点?
牛羚发现
find dir -mindepth 2 -maxdepth 2 -type f -execdir sh -c 'mv -t ./*/ "$1"' find-sh {} \;
find dir \
-mindepth 2 -maxdepth 2 -type f \
-execdir sh -c '
mv -t ./*/ "$1"
' find-sh {} \;
原始目录结构
dir
├── dirA/
│ ├── fileA
│ └── subdir/
│ ├── e
│ ├── q
│ └── w
└── dirB/
├── fileB
└── subdir/
├── c
├── x
└── z
移动后
dir
├── dirA/
│ └── subdir/
│ ├── e
│ ├── fileA
│ ├── q
│ └── w
└── dirB/
└── subdir/
├── c
├── fileB
├── x
└── z
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句