Issue
I am confused to how to copy a specific type of files from a folder structure to simply a folder on a LINUX machine.
This is how the source folder structure is:
Folder_X
file1.type
file2.nottype
- Folder_Y
file3.type
file4.nottype
- Folder_P
file5.type
file6.nottype
- Folder_A
file7.type
file8.nottype
- Folder_Z
file9.type
file10.nottype
So When I do find . -iname "*.type"
in Folder_X, I get following output
./file1.type
./Folder_Y/file3.type
./Folder_Y/Folder_P/file5.type
./Folder_Y/Folder_P/Folder_A/file7.type
./Folder_Z/file9.type
I want to copy these .type
extension files to another location in a single folder as this
/some/another/location/Folder_I
file1.type
file3.type
file5.type
file7.type
file9.type
Any help is appreciated... Thank you for time
Solution
try below code,
The find command has a -exec option.
ref : https://man7.org/linux/man-pages/man1/find.1.html
find . -iname "*.type" -exec cp {} /some/another/location/Folder_I \;
Answered By - myeongkil kim Answer Checked By - Clifford M. (WPSolving Volunteer)