If i have a directory A that contain directories B , C , D I need a script that search
Directories B , C , D for .deb files and if found copy them to a location i choose .
This script should reduce effort of hand search and copy .
Any idea ?
If i have a directory A that contain directories B , C , D I need a script that search
Directories B , C , D for .deb files and if found copy them to a location i choose .
This script should reduce effort of hand search and copy .
Any idea ?
If you don't need to search recursively, then a simple bash brace expansion
cp -t /location/you/choose/ /path/to/A/{B,C,D}/*.deb
should work. If you want to search all subdirectories of A recursively, then the most portable way would probably be
find /path/to/A -name '*.deb' -exec cp -t /location/you/choose/ {} +
If your shell supports it, you could also use the globstar
shell option to make cp
recursive without using find
- type shopt
or help shopt
at the shell prompt for more information. If you need to exclude certain subdirectories then you could add a -prune
to the find command.
As always you need to think ahead about what you want to do in case of non-unique filenames - you could add a -n
or --no-clobber
to the cp
command, or use the --backup=numbered
option. In the case of deb files it probably doesn't matter, since (barring file corruption) any non-unique filenames should correspond to exact duplicate files.