I kind of got stuck in a situation. I wanted to copy certain files from one directory to another (non recursive).
I have multiple files with extensions like .txt
, .so
, .so.mem
, .so.lib
, .lib
and multiple directories in a directory called base
. I'd like to copy all the files non-recursively (only from the base directory) to another directory called test
.
I did the following:
Try 1
pushd $base
find -not -name '*.so' -not -name '*.so.*' -type f -print() -exec rm -f {} +
cp -f $base/* $test
In above try the find has somehow deleted all except .so
, even though I have written -not -name '*.so.*'
i.e. files .so.mem
and .so.lib
should not be deleted.
Am I doing something wrong ?