Note that this example does not work, I need to translate the DONT_COPY list to a better format. How can I do that?
Later in the script I compare the list of items in COPIED to a DO_COPY list so that the user could examine them at his leisure and decide whether or not to include them in future backups.
If on linux, you can either use --exclude-from and add the files to exclude into the file or you will have to use one --exclude for each pattern you want to exclude from tar.
$cat files_to_exclude
.adobe/
.bin/google-earth
$ tar -zcf --exclude-from=files_to_exclude file.tgz *
OR
$ tar -zcf --exclude=.adobe --exclude=bin/google-earth file.tgz *
Thanks! I had to change that to write to a variable, as it is in a script:
DONT_COPY_LIST=""
for pattern in $DONT_COPY ; do DONT_COPY_LIST="$DONT_COPY_LIST --exclude=$pattern "; done
However, it fails on spaces. The linux-wife balance is greatly upset by demanding no spaces in filenames, so the DONT_COPY list looks more like this (sorry that I did not think of this earlier):
DONT_COPY="
.adobe/
File with Spaces
.bin/google-earth
Yet Another Annoying Filename
"
I tried replacing DONT_COPY in the second line with quotes, but this did not help (it created a different problem). How can I work with spaces in filenames?
I appreciate your patience and advice. I have googled this, but I can find no examples in which one is working with a list like this.
---------- Post updated at 11:30 PM ---------- Previous update was at 07:10 PM ----------