Prev: Writing & Editing Jobs
Next: find command
From: 105 on 30 Jun 2010 19:43 using ditto for a targeted backup which has a directory with a space in directory name (FileMaker Server). Mac OS/server 10.6.4 What is the preferred syntax/escape for handling the space: quoting the offending name or backslashing prior to the space? #!/bin/sh ditto -c -k -rsrc /Library/"FileMaker Server"/Data/Backups/Hourly/Volumes/xsrv/Users/Shared/fms_backups/`date +%y-%m-%d`_test.zip or: #!/bin/sh ditto -c -k -rsrc /Library/FileMaker\ Server/Data/Backups/Hourly /Volumes/xsrv/Users/Shared/fms_backups/`date +%y-%m-%d`_test.zip
From: John Kelly on 30 Jun 2010 20:03 On Thu, 01 Jul 2010 09:13:04 +0930, 105 <cortical(a)internode.on.net> wrote: >using ditto for a targeted backup which has a directory with a space in >directory name (FileMaker Server). Mac OS/server 10.6.4 > >What is the preferred syntax/escape for handling the space: quoting the >offending name or backslashing prior to the space? > > >#!/bin/sh >ditto -c -k -rsrc /Library/"FileMaker >Server"/Data/Backups/Hourly/Volumes/xsrv/Users/Shared/fms_backups/`date >+%y-%m-%d`_test.zip > >or: > >#!/bin/sh >ditto -c -k -rsrc /Library/FileMaker\ Server/Data/Backups/Hourly >/Volumes/xsrv/Users/Shared/fms_backups/`date +%y-%m-%d`_test.zip In my shell (bash), both methods seem to work. So if that's your shell too, I suppose you can use either. OTOH, if you're fanatic about minimalism, the backslash only requires one character, whereas the quote pair requires two. -- Web mail, POP3, and SMTP http://www.beewyz.com/freeaccounts.php
From: 105 on 30 Jun 2010 20:48 On 1/07/10 9:33 AM, John Kelly wrote: > On Thu, 01 Jul 2010 09:13:04 +0930, 105<cortical(a)internode.on.net> > wrote: > >> using ditto for a targeted backup which has a directory with a space in >> directory name (FileMaker Server). Mac OS/server 10.6.4 >> >> What is the preferred syntax/escape for handling the space: quoting the >> offending name or backslashing prior to the space? >> >> >> #!/bin/sh >> ditto -c -k -rsrc /Library/"FileMaker >> Server"/Data/Backups/Hourly/Volumes/xsrv/Users/Shared/fms_backups/`date >> +%y-%m-%d`_test.zip >> >> or: >> >> #!/bin/sh >> ditto -c -k -rsrc /Library/FileMaker\ Server/Data/Backups/Hourly >> /Volumes/xsrv/Users/Shared/fms_backups/`date +%y-%m-%d`_test.zip > > In my shell (bash), both methods seem to work. So if that's your shell > too, I suppose you can use either. > > OTOH, if you're fanatic about minimalism, the backslash only requires > one character, whereas the quote pair requires two. > > > thanks John Yes both methods work. I did notice that Smultron (text editor) red flags the quoted string. I knew that drag/dropping the directory onto a terminal loaded the path at the prompt, I just recognized during some testing that the loaded path uses the backslash syntax, so I'll take that as a anointment from the demigods of unix coding past :-)
From: Thomas 'PointedEars' Lahn on 1 Jul 2010 02:43 105 wrote: ^^^ Something is borken there. > using ditto for a targeted backup which has a directory with a space in > directory name (FileMaker Server). Mac OS/server 10.6.4 > > What is the preferred syntax/escape for handling the space: quoting the > offending name or backslashing prior to the space? > > #!/bin/sh > ditto -c -k -rsrc /Library/"FileMaker > Server"/Data/Backups/Hourly/Volumes/xsrv/Users/Shared/fms_backups/`date > +%y-%m-%d`_test.zip I would not do this, but instead ditto -c -k -rsrc "/Library/FileMaker Server/Data/Backups/Hourly/Volumes/xsrv/Users/Shared/fms_backups/$(date +%y-%m-%d)_test.zip" I would want quote the entire positional argument so that it is clear what the argument is. Also makes refactoring easier, like base='/Library/FileMaker Server/Data/Backups' dir="$base/Hourly/Volumes/xsrv/Users/Shared/fms_backup" today=$(date +%y-%m-%d) ditto -c -k -rsrc "${dir}/${today}_test.zip" And I tend to use $(…) instead of `…` because it is less ambiguous (consider e.g. x=`ls -l `which acroread`` vs. x=$(ls -l $(which acroread)) and allows for more complex expressions inside (especially other `…`). Depends on the shell, though; must be a POSIX-compliant one, the original Bourne shell (1978 CE) supported only backticks for command substitution. > or: > > #!/bin/sh > ditto -c -k -rsrc /Library/FileMaker\ Server/Data/Backups/Hourly > /Volumes/xsrv/Users/Shared/fms_backups/`date +%y-%m-%d`_test.zip This should be used automatically with Tab completion on the command line. I would want to avoid it in a shell script, the savings are not worthwhile. HTH -- PointedEars
From: 105 on 1 Jul 2010 09:05 thanks Thomas testing locally for simplicity this works: src='/Library/AAABBB/CCC/' dst='/Users/Shared/fms_backups/' today=$(date +%y-%m-%d) ditto -c -k -rsrc ${src} ${dst}${today}_test.zip but when the source path has an escape requirement this is required: src='/Library/AAA BBB/CCC/' dst='/Users/Shared/fms_backups/' today=$(date +%y-%m-%d) ditto -c -k -rsrc "${src}" ${dst}${today}_test.zip or with uniform syntax: src='/Library/AAA BBB/CCC/' dst='/Users/Shared/fms_backups/' today=$(date +%y-%m-%d) ditto -c -k -rsrc "${src}" "${dst}${today}_test.zip" with src = AAA BBB quoting the last: ditto -c -k -rsrc "${src} ${dst}${today}_test.zip" returns ditto: no destination with src = AAA BBB quoting the last: ditto -c -k -rsrc ${src} ${dst}${today}_test.zip returns ditto: Can't archive multiple sources so the moral is double quote the from to ditto components individually
|
Pages: 1 Prev: Writing & Editing Jobs Next: find command |