Baruch Siach
Thu, 04 Feb 2010 11:49:38 -0800
Hi Dotan, On Thu, Feb 04, 2010 at 09:12:54PM +0200, Dotan Cohen wrote: > 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!
How about:
rm -f /tmp/excludes
for pattern in $DONT_COPY ; do echo ${DONT_COPY} >> /tmp/excludes; done
tar -X /tmp/excludes -zcvf - *
Note that this won't archive files with spaces in their file names.
baruch
--
~. .~ Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
- bar...@tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -
_______________________________________________
Linux-il mailing list
Linux-il@cs.huji.ac.il
http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il