简体   繁体   中英

Enter multiple directories, enter subdirectories, and move all files up one directory with bash

I have multiple directories like:

T1_5356
T1_5357
T1_5358
.
.

Each directory has a sub-directory called DTI

I would like to enter each directory and copy the contents of its respective DTI contents up one directory (so cp T1_5356/DTI/*../ )

I have been trying variations of:

for dir in T1*; do cd $dir; cp -r DTI/*; cd ../; done

but I get an error: cp: cannot stat `DTI/*': No such file or directory

from inside the directory that contains all the T1_* directories:

for dir in T1_*; do cp $dir/DTI/* $dir; done

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM