1
0
//// SOLVED ////
I'm trying to copy several files scattered in a directory structure to another one where such files already exist but without write permission allowed. So I used a find command with two -exec options (-ok option, here, just to debug), the first for the chmod command and the second for the cp command with two references to {}.
I think the problem is how to join the destination root path to the variable {}. I tried other ways to join those paths without exit.
I know I can do it with other tools (sed, awk, perl, bash script, send the find results to a file a process it in a second stage, ...) but I thought this one was the simpler.
Do you know if exist any way to make it to work? Thanks in advance.
$ cd ~/sourceBranch/
$ find . \( -name '*.h*' -o -name '*.c*' \) -a -ctime -1 -ok chmod -v u+w /tmp/destBranch/{} \; -ok cp -uv {} /tmp/destBranch/{} \;
However I get this output (shown only for first file found):
< chmod ... ./Node/Db/UtilCLib/src/Constants.cc > ? yes
mode of `/tmp/destBranch/' retained as 0755 (rwxr-xr-x) <--- wrong path
< cp ... ./Node/Db/UtilCLib/src/Constants.cc > ? y
`./Node/Db/UtilCLib/src/Constants.cc' -> `/tmp/destBranch/Constants.cc' <--- wrong path
After sending this question I realized that I forgot to protect the {} variables with quotes! Now it works properly. Sorry if you had lost time by reading it. – Yandot – 2012-11-21T12:08:22.237
Please do one or more of the following: (1) Post your answer *as an answer* and accept it and/or upvote it, so people will be able to see immediately that you don’t still need help; (2) Edit your question (ideally, at the top) to indicate that you don’t still need help; and/or (3) Delete your question. (I realize that you might not have sufficient privileges to do all of these options.) – Scott – 2012-11-22T01:02:27.970
@Scott Thanks for the advices but I was not able to upvote my own answer, so I added a "SOLVED" on top of the question. I hope it is enough to avoid people lose time with it. – Yandot – 2012-11-23T18:32:44.040