1

What I'm trying to achieve is copying everything at source directory to destination directory by excluding the workspace directory, I have the following command to do so:

rsync -av --exclude='directory-name*/workspace' sourceDir destinationDir

which is working well, but if I try to use variable for the "directory-name":

VARIABLE_NAME="directory-name"
rsync -av --exclude='$VARIABLE_NAME*/workspace' sourceDir destinationDir
Cyrus
  • 84,225
  • 14
  • 89
  • 153
Canberk Ozcelik
  • 631
  • 1
  • 11
  • 26

1 Answers1

3

Variables are not expanded when put inside single quotes, use double quotes instead:

rsync -av --exclude="$VARIABLE_NAME"'*/workspace' sourceDir destinationDir
heemayl
  • 39,294
  • 7
  • 70
  • 76