Re: whats wrong with find -exec sed?



On 2006-11-02 14:04, tom wrote:
Hi there,

i am getting mad. whats wrong with this?

find . -iname "*.pl" -exec sed 's/[.\/]*\/perl\/bin\/perl -I[.\/]*\/perl\/lib/\/usr\/bin\/perl/w {}' {}\;

note: everything is in one line. Thunderbird makes 2 of it.


I want to find all perl files ending with .pl, get them sed'ed and write back the result. It works without writing the files back and I can even produce one big file with all changes in it. But I need the changes in every single file.

What's wrong with that approach? Bash tells me "find: missing argument to `-exec'"

Thanks so much,

Thomas

Since you know what perl is, why not use it :-)

perl -pi -e 's,from,to,' `find . -iname \*.pl -print`

As other writes, you are not forced to use / as delimiter ,
so in this case, use , or something else.

If you have space in the filename of your perl scripts, this will fail,
and you must use:

find . -iname \*.pl -print0 | xargs -0 perl -pi -e 's,from,to,'


/birre
.



Relevant Pages

  • whats wrong with find -exec sed?
    ... i am getting mad. ... whats wrong with this? ... Thunderbird makes 2 of it. ... I want to find all perl files ending with .pl, get them sed'ed and write back the result. ...
    (alt.os.linux)
  • Re: whats wrong with find -exec sed?
    ... Thunderbird makes 2 of it. ... I want to find all perl files ending with .pl, ... It's not bash that tells you that - it's find. ... Safer would be: ...
    (alt.os.linux)