For example, I want to execute the following within a shell script:tar cvpzf /destination/backup.tgz /directory\ one /directory\ twoI wish to assign the list of paths (with whitespaces in them) to a variable at the top portion of a script, for easy maintenance.How would one assign /directory\ one /directory\ two to a variable and then pass it on later, for example, to tar, i.e.:#!/bin/shbackup_dirs=?????????tar cvpzf /destination/backup.tgz $backup_dirswithout causing tar to interpret /directory and one as separate entities, just how it would not do so when one executes it in the command line?
Pass list of directories (that contain whitespaces) to a command in a script
bash;shell;shell script;quoting;whitespace
Just quote it:dir1=directory 1dir2=directory 2tar cvpzf /destination/backup.tgz $dir1 $dir2Or, if your shell supports it (bash, which you've tagged your question with, does but sh, which you are using in your script doesn't)  use arrays:targets=( directory 1 directory 2 )tar cvpzf backup.tgz ${targets[@]}