I have a folder structure that contains a bunch of files named "swagger.json" and I need to copy them to a destination folder without overwriting. The expected result is:


I'm using the following command:

find . -type f -name "swagger.json" -exec cp --backup=numbered {} ~/Downloads \;

But the result is that the download folder has always one swagger.json. What am I doing wrong?

OK FOUND IT The files are there. But they are hidden. Guess I was owned by my file explorer.

closed as off-topic by Gilles, Jeff Schaller, xhienne, Stephen Rauch, Archemar Aug 9 '17 at 9:11

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions describing a problem that can't be reproduced and seemingly went away on its own (or went away when a typo was fixed) are off-topic as they are unlikely to help future readers." – Gilles, xhienne, Stephen Rauch, Archemar
If this question can be reworded to fit the rules in the help center, please edit the question.

  • I believe it SHOULD have one swagger.json file. You are telling it not to overwrite that file but if it doesn't exist yet there is nothing to overwrite. So it will copy the first swagger.json file as is and then append (#) to all additional files so that they don't overwrite the first. – Jesse_b Aug 8 '17 at 16:33
  • @Jesse_b I believe that if I run this command twice at least a swagger(1).json should exist right? Well it does't... – Marcelo de Aguiar Aug 8 '17 at 16:35
  • I'm not sure what the issue is anymore. Your question says: "But the result is that the download folder has always one swagger.json." Which to me indicates that you don't want to see any files named swagger.json but you didn't mention that none of the files are being appended with a number. Upon running that command myself I found that it doesn't seem to work quite the way you want anyway. When I run it, it appends my files as follows: alert_email.sh becomes alert_email.sh.~1~ – Jesse_b Aug 8 '17 at 16:38

Browse other questions tagged or ask your own question.