Thursday, May 2, 2024
2
rated 0 times [  2] [ 0]  / answers: 1 / hits: 6078  / 2 Years ago, sat, february 5, 2022, 2:01:22

I have folder named datahub and it has 15 folders and more than 20 subfolder which holds .jar files. I wanted to find all .jar files from subfolders and copy back to my current directory.



I am referring Bash - create zip by finding files but this is copying subfolders as well, but i wanted to copy only .jar's to my current directory or to create one directory and copy to it.



Thanks in Advance for your help
Venkat


More From » command-line

 Answers
7

Open Terminal and navigate to your source directory.



find ./ -name "*.jar" -print0 | xargs -0 cp -t "Destination"


This only works if the file names are unique and are not already inside the Destination folder.


[#5095] Monday, February 7, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
turhizz

Total Points: 82
Total Questions: 106
Total Answers: 96

Location: South Korea
Member since Mon, Dec 6, 2021
2 Years ago
;