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
  • 77,979
  • 13
  • 71
  • 125
Canberk Ozcelik
  • 621
  • 1
  • 12
  • 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
  • 35,775
  • 6
  • 62
  • 69