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

I want to find "old" folders in /volume1/photo/ipcam which are named like "????-??-??" and move corresponding folders within dropbox (with the same directory structure /ipcam/...) to the subfolder /ipcam/archive. The find command below (with the appropriate values used instead of the variables) works fine when used on the commandline but doesn't if used in a script:

via commandline:

find /volume1/photo/ipcam -maxdepth 1 -type d -name "????-??-??" -mtime +0 -exec sh -c 'echo /home/pi/Dropbox-Uploader/ move /ipcam/$(basename {}) /ipcam/archive' \;

via script:



find $source -maxdepth 1 -type d -name "????-??-??" -mtime +0 -exec sh -c '$dropboxtool move $dropbox/$(basename {}) $dropboxarchive' \;

I think something is wrong with the quotes in the "script" version, but not sure.

PS: using the following version on the raspberrypi: Linux raspberrypi 3.10.24+ #614 PREEMPT Thu Dec 19 20:38:42 GMT 2013 armv6l GNU/Linux

share|improve this question
Variables don't get substituted inside single quotes. Try double quotes instead: ...-exec sh -c "$dropboxtool move ..." \;. In your command line version you didn't used variables at all, so this worked. – mpy Feb 18 '14 at 19:42
thanks for your tip! You're right with the double quotes -exec sh -c "$dropboxtool move $dropbox/$(basename {}) $dropboxarchive" \;. But now I have another problem with the statement in the script: The $(basename {}) doesn't work correctly - instead of the name of the folder the whole pathname including the folder name has been substituted /volume1/photo/ipcam/2014-02-20. Do you have another tip to solve also this problem? – Martin Gross Feb 22 '14 at 12:08
@mpy why don't you add your correct answer as a official answer? :) – Bohne Sep 26 '15 at 13:39

You must log in to answer this question.

Browse other questions tagged .