This script doesn't use any Gnu specific feature so should work with any Unix / POSIX system:
find projects/ -name "*.php" -exec sh -c 'for i do
mkdir -p `dirname copy/$i`
(set -x; cp -i $i copy/$i)
done' - {} +
Question
I want to copy over only files ending with .php to another dir:
In Linux i have this command:
find projects/ -name '*.php' -exec cp -iv --parents -t copy/ {} +
In Mac this is also working:
find projects/ -name '*.php' -exec gcp -iv --parents -t copy/ {} +
In Solaris 10:
cp: illegal option -- v
cp: illegal option -- parents
cp: illegal option -- t
I read the man page, but could not find a solution.
Do you know how to solve it ?
Solution
This script doesn't use any Gnu specific feature so should work with any Unix / POSIX system:
find projects/ -name "*.php" -exec sh -c 'for i do
mkdir -p `dirname copy/$i`
(set -x; cp -i $i copy/$i)
done' - {} +
OTHER TIPS
I found another one liner working for me on solaris:
find projects/ -name '*.php' -print | cpio -pdm copy/