0

I have a very simple bash script that I'm trying to get to work. The goal of the script is to take the current working folder and sync it with the target folder with the same name on an external drive, creating a new folder on the external drive if necessary.

#!/bin/sh
rsync --verbose --recursive ${PWD} /path/to/drive/${PWD##*/}

The above is the script. Instead of creating /path/to/drive/newfolder/, it's creating /path/to/drive/newfolder/newfolder/. What have I done wrong?

1 Answers1

0

You need to add a slash after the foldername on the left to indicate you want to sync the contents of the folder over.

rsync --verbose --recursive ${PWD}/ /path/to/drive/${PWD##*/}
zeroimpl
  • 2,746
  • 22
  • 19