问题
I have a input path src
and output path dest
. src
can have multiple sub-directories, which can again have further sub-directories and so on. I want to copy all java files (and directories that contain them) from src
to dest
"as-is". That is, if src
was:
src -
f1.java
f4.txt
dir_1 -
f2.java
dir_2 -
f3.java
dir_3 -
f5.txt
dest
should look like:
dest -
f1.java
dir_1 -
f2.java
dir_2 -
f3.java
I tried:
cp src/*.java dest
But it only copies f1.java
, and nothing else. Can someone please help me out? (with solution/hints/links -- anything is good). I'm using ubuntu
回答1:
Just cd into /path/to/src
, and run this:
find -type f -name '*.java' -exec cp --parents -t /path/to/dest {} +
来源:https://stackoverflow.com/questions/62232646/copy-all-java-files-to-specified-folder