0

I want to do the following.

I want to copy from a remote FTP server every day certain files. This FTP directory is mounted. Every day a directory is created and within that directory I need 3 files of the 5

dir1
dir2
dir3

I want to copy every day the files with certain extensions to dir999

cp */*.img /dir999 

But will that copy every day all files again ? as its a lot i only want to do the changes.

  • Hi, i want this automated, so that i can do it in a crontab and every day download only the new files from the new directories that were created. – mamoman May 30 '17 at 6:57
  • Sounds like you are looking for rsync. There are dozens of questions like this here so you might want to examine them for a suitable duplicate rather than posting a new question. – tripleee May 30 '17 at 8:23
1

Many implementations of cp like FreeBSD, GNU and MacOS have an option -n to skip existing files. So with

cp -n */*.img /dir999

you will only copy new files. Note that changed files won't get updated in the destination directory. If you want this, you'd need a different solution.

  • stupid me, yes that is what i needed. Thank you. – mamoman May 30 '17 at 8:30
  • @mamoman there are no stupid people here :-) If this answer works for you please remember to accept it with the tick mark in the corner. – roaima May 30 '17 at 9:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.