I'm trying to replace files that match a particular pattern* on CentOS, but it is not working.
I initially wrote:
cp example.com/(*)/orm-mysql/build/conf/(*)-conf.live.php example_dev.com/$1/orm-mysql/build/conf/$1-conf.live.php
I want to replace the files in the example_dev.com
directory with the files of the same name in example.com
.
*The pattern is example.com/
then anything until /orm-mysql/build/conf/
then a file prefixed with the first wildcarded value and ending in -conf.live.php
.
I tried using find
with exec
:
find /var/www/html/example.com -name '*/orm-mysql/build/conf/*-conf.live.php' -exec echo {} \;
but it threw an error:
find: warning: Unix filenames usually don't contain slashes (though pathnames do). That means that '-name ‘*/orm-mysql/build/conf/*-conf.live.php’' will probably evaluate to false all the time on this system. You might find the '-wholename' test more useful, or perhaps '-samefile'. Alternatively, if you are using GNU grep, you could use 'find ... -print0 | grep -FzZ ‘*/orm-mysql/build/conf/*-conf.live.php’'
Which I think is because -name
is for a file, not a path.
How can I accomplish this, is there an easier way than writing a shell script?
Some examples:
/var/www/html/example.com/video/orm-mysql/build/conf/video-conf.live.php
/var/www/html/example.com/images/orm-mysql/build/conf/images-conf.live.php
/var/www/html/example.com/audio/orm-mysql/build/conf/audio-conf.live.php
and they would replace:
/var/www/html/example_dev.com/video/orm-mysql/build/conf/video-conf.live.php
/var/www/html/example_dev.com/images/orm-mysql/build/conf/images-conf.live.php
/var/www/html/example_dev.com/audio/orm-mysql/build/conf/audio-conf.live.php
*
? That wouldn't really work anyway. Could you give us some example file names? I assume that the$1
you are using, although not recognized by cp/shell, means that the file name also has the directory name in it, is that correct?wholename
andsamefile
but got the same error. I'm not sure what I'm suppose to put in place of the...
in their example