简体   繁体   中英

Script to find files in subdirectories

I need a script that will find and get me all files in all subdirectories (and leave them in the folder structure as they are now). I know how to find and print that files:

find . -name "something.extension"

The point is, in those directories are lots files that was used before, but I don't want to get those, so the script should only find me files that matches some kind of path pattern which is:

xxx/trunk/xxx/src/main/resources

xxx is different everytime, and after resources there are still some folders that directories are different based on xxx.

Every top xxx folder contains folder named 'tags' (the same level as trunk) that stores previous releases of module (and every release has files that name I am looking for, but I don't want outdated files).

So I want to find all that files in subdirectories of that path pattern that I specified and copy to new location but leave folder structure as it is right now.

I am using Windows and cygwin.

Update

I combined answer commands that 'that other guy' posted below, and it works. Just to be clear I have something like this:

find */trunk/*/src/main/resources -name "something.extension" -exec mkdir -p /absolute/target/path/{} \; -exec cp {} /absolute/target/path/{} \;

Thanks.

而不是在整个当前目录( . )下搜索,只需在您关心的目录下搜索:

find */trunk/*/src/main/resources -name "something.extension"

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