[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: strange behaviour in find
From: |
David D |
Subject: |
Re: strange behaviour in find |
Date: |
Wed, 19 Dec 2001 12:06:02 +0100 |
you r rigth "$i" prevent from spacing char dir.
> "David D" <dd@asi.fr> 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
>
>
> paul