Excluding a list of files from tar with spaces in filenames

Excluding a list of files from tar with spaces in filenames

Dotan Cohen dotancohen at gmail.com
Thu Feb 4 21:12:54 IST 2010


I hope there is a bash guru out there today. I need to script a backup
plan which has a list of directories that should not be backed up.
Some of these directories have spaces in their filenames. The
following script works so long as there are no directories with spaces
in DONT_COPY, however, I cannot figure out what to do to get it to
work _with_ spaces in filenames:

#!/bin/bash

DONT_COPY="
.adobe/
File with Spaces
.bin/google-earth
Yet Another Annoying Filename
"

DONT_COPY_LIST=""
for pattern in $DONT_COPY ; do DONT_COPY_LIST="$DONT_COPY_LIST
--exclude=$pattern "; done
tar -zcvf - * $DONT_COPY_LIST


Any ideas? Thanks!

-- 
Dotan Cohen

http://what-is-what.com
http://gibberish.co.il

Please CC me if you want to be sure that I read your message. I do not
read all list mail.



More information about the Linux-il mailing list