[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: strange behaviour in find

From: Paul Jarc
Subject: Re: strange behaviour in find
Date: Tue, 18 Dec 2001 13:51:57 -0500
User-agent: Gnus/5.090004 (Oort Gnus v0.04) Emacs/20.7 (i386-redhat-linux-gnu)

"David D" <address@hidden> wrote:
> bash: {}/common2.inc.php:  no such file or directory
> Here is the command
> find -type d -name include -exec sed "s/toto1/toto2/g" {}/common.inc.php >
> {}/common2.inc.php \; -exec mv -f {}/common2.inc.php {}/common.inc.php \;

Is the command really split across two lines like that?  That will
cause each line to be interpreted as a separate command.  (And the
first will be a syntax error, since it ends with ">".)

Even if you fixed that, it still wouldn't work, because you're giving
sed an argument ">" and expecting redirection to happen.  Redirection
is handled by the shell, not sed.  So you need find to run a shell
which runs sed with the redirection.  Try this:
  find -type d -name include -exec /path/to/script '{}' \;
Where /path/to/script contains:
#!/bin/sh -e
sed 's/toto1/toto2/g' "$1"/common.inc.php > "$1"/common2.inc.php
mv -f "$1"/common2.inc.php "$1"/common.inc.php


reply via email to

[Prev in Thread] Current Thread [Next in Thread]