bogdan wrote:
Can anyone suggest an approach to check for files existence using only their extension? For example, I need to check if in a given directory are files with the extension *.cls, and if yes copy all these files in another location.
You might want to use find: `find . -name \*.tgz -exec cp {} /path/to/new/location'
This will look for .tgz files in the current directory and copy them to path/to/new/location.
Be aware that it searches recursivly, so you would need to define the maxdepth parameter:
find . -maxdepth 1 -name \*.tgz -exec
Two examples:
Code:
find . -name \*tgz
./Desktop/network.tgz
./Desktop/git-1.5.2.4/backup-072820070107-pre-git-fvcs.tgz
./sbox/ip-allocation.tgz
./sbox/bashbot.tgz
./sbox/logger.tgz
./shell.tgz
./kqemu-0.3Alpha.tgz
./network.tgz
find: ./.cpan/build/XML-SAX-Expat-0.39: Permission denied
./ip-allocation.tgz
find . -maxdepth 1 -name \*.tgz
./shell.tgz
./kqemu-0.3Alpha.tgz
./network.tgz
./ip-allocation.tgz