This is the mail archive of the cygwin mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: Problem with spaces embedded in filenames

I've always had problems getting the correct number of backslashes.  Try
quotes.  For example, change sed to

	sed -e 's/^.*$/"&"/'

to give


If that doesn't work, try doubling them 

	sed -e 's/^.*$/"&"/' -e "s/^.*$/'&'/"

to give


You might need to change which quotes are on the inside/outside.

If that isn't enough protection, feed the quoted file names into a file and
then use

	... `cat file`

Alternatively, you could check the tar documentation to see if it can take
the file list from a file or standard input.  Or it might even be able to do
the date selection for you instead of using find -- that should avoid
quoting problems.

-----Original Message-----
From: Will Senn
Sent: Thursday, June 03, 2004 5:04 PM
Subject: Problem with spaces embedded in filenames

Hash: SHA1

I am doing backups with tar on XP. I thought that I could touch a file
when I did a full backup and then use find with newer to only back up
files that are newer than the touched file:

~    touch /cygdrive/i/backups/full_backup
~    find /cygdrive/d/sandbox -newer /cygdrive/i/backups/full_backup !
~    -type d -print | sed -e "s/\ /\\\\ /g"`

this command produces the following list of files:

~    /cygdrive/d/sandbox/another\ test.txt
~    /cygdrive/d/sandbox/test.txt

'another test.txt' is a file with an embedded space (I figured I
needed to escape the space, hence the sed)

The problem is this, when I use the output of this command as the
input of another it complains. ie.

~    $ ls -l `find /cygdrive/d/sandbox -newer
~    /cygdrive/i/backups/_sandbox.full ! -type d -print | sed -e "s/\
~    /\\\\ /g"`

~    ls: /cygdrive/d/sandbox/another: No such file or directory
~    -rwx------+   1 wsenn    None            0 Jun  3 14:45
~    /cygdrive/d/sandbox/test.txt
~    -rw-r--r--    1 wsenn    None           69 Jun  3 15:26 test.txt

Any help would be appreciated. Here's the tar command I planned on using:

~    tar czf /cygdrive/i/${TODAY}_I_sandbox.tgz `find
~    /cygdrive/d/sandbox -newer /cygdrive/i/backups/full_backup ! -type
~    d -print | sed -e s/\ /\\\\\ /g`


Version: GnuPG v1.2.4 (MingW32)
Comment: Using GnuPG with Thunderbird -

Unsubscribe info:
Problem reports:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]