SEARCH AND COPY FILES IN LINUX. | FIND | CP
Search for zip files inside sub-directories and copy all zip files.
# Directory where all .zip files are located is zipfiles-dir.
Command :
- GO TO ZIP FILE DIRECTORY.
cd zipfiles-dir
—————————————————————————————–
2. RUN BELOW COMMAND INSIDE DIRECTORY.
find . -iname *Slides.zip -exec cp {} /root/test/ \;
Describe above command.
find : Command to find files and directories in Linux system.
. : We use . as location means current directory.
–name *Slides.zip : Search for file name matching with extension *Slides.zip, It means All .zip files which name ends with Slides.zip.
–exec cp : excecute to cp command to to copy files form source directory to destination directory.
{} : Files found by FIND command will be automatically replace by filename.
/root/test/ : Destination diectory where all searched files are copied.
\ : Indicates that executed command is completed.
—————————————————————————————-