multiple exclusions

Normally, multiple exclusion in rsync is :
rsync [args] --exclude=excl1 --exclude=excl2 ... --exclude=excln [source] [destination]

however in real scenario if the person is looking for reuse concept and modularity and doing the job fundamentally, will think “what if or how to prevent writing --exclude every time and rely on software development concepts on string rendering on … therefore that comes to mind we store the paths into an array (or a long string with separator) "
then it will be like bellow

exclude_paths=("/dev/" "/media/" "/mnt/" "/opt/" "/proc/" "/run/" "/home/user/Desktop/gdrive_online/" "/home/user/.*")




for path in "${exclude_paths[@]}"; do

    excls_str+=" --exclude=${path}"


command="rsync -av$excls_str $source $destination"

echo $command


However, it can be even better. For example, relying on runtime to specify the exclusions and source and destination using GUI.