Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

//// 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
share|improve this question
    
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 Nov 21 '12 at 12:08
    
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 Nov 22 '12 at 1:02
    
@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 Nov 23 '12 at 18:32

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.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .