On Wed, May 24, 2000 at 07:20:35AM +1000, Angus Lees wrote:
| On Wed, May 03, 2000 at 09:10:51PM +1000, Terry Collins wrote:
| > Nick Croft wrote:
| > ...snip....
| > >         -exec mv {} somedirectory \;
| > 
| > Yep, it is in the archive {:-).
| > Hmm, I really need something like mhonarc for multiple directories.
| > 
| > There is a way of quoting that I can never remember that makes -exec
| > work
| > 
| > something like -exec \{  }\ ;

Nick's example had it exactly right. The ; needs quoting because otherwise it
acts as a command terminator (like newline does).

| -exec \{\} \;  (or "-exec '{}' ';'" or some combination)
| you just have to stop the braces and comma being interpreted by the
| shell

Just the semi. If you actually read the shell manual you'll find that {
and } are not punctuation, they're ordinary characters like letters,
digits dashes etc. Just because you see things like

        [ -s somefile ] || { echo "missing somefile" >&2; exit 1; }

for grouping doesn't make them punctuation. "{" and "}" are simply
keywords like "if" and "then", and special only when they're the first
word of a command (which is why the ";" before the closing "}" in the
example code above, to make the "}" a command name).

| also, providing you are under the command line length, this is usually
| faster:
|  mv `find . -print` somedirectory
| since it only starts one find and one mv, instead of one mv per file

I trust you've never run that one. You're right about the performance issue
but the above
        - breaks on filenames with spaces etc in them
        - will try to move the directories as well as the files

The {} notation does the right quoting (by calling exec() directly and not
using the shell at all, thus obviating the need for quoting).
-- 
Cameron Simpson, DoD#743        [EMAIL PROTECTED]    http://www.zip.com.au/~cs/

Loose lids kink squids. - [EMAIL PROTECTED] DoD#275
--
SLUG - Sydney Linux Users Group Mailing List - http://www.slug.org.au
To unsubscribe send email to [EMAIL PROTECTED] with
unsubscribe in the text

Reply via email to