bug-bash
[Top][All Lists]
Advanced

[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: Tue, 18 Dec 2001 20:26:41 +0100

It seems to work, the wasn t splitted as you could read.

In a frenchy group I found :

for i in $(find -type d -name include); do
sed "s/toto1/toto2/g" $i/common.inc.php > $i/common2.inc.php
mv -f $i/common2.inc.php $i/common.inc.php
done

or :

find -type d -name include | while read i;
do sed "s/toto1/toto2/g" $i/common.inc.php > $i/common2.inc.php;
mv -f $i/common2.inc.php  $i/common.inc.php; done

as u like.



> "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
>
>
> paul





reply via email to

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