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?