xargs_hints

This is part of The Pile, a partial archive of some open source mailing lists and newsgroups.



Subject: Re: [sf-perl] inplace editing in 5.6
From: Garth Webb <garth@redhat.com>
Date: Wed, 28 Jun 2000 12:46:48 -0700


"Matthew D. P. K. Strelchun-Lanier" wrote:
> 
> hey-
> 
> i want to verify that i'm not on crack, and that this should work...
> 
> perl -p -i.bak -e "s/reqfields/reqinsertfields/g;" `find . -name "*.pm" |
> xargs grep -n reqfields`
> 
> i get the following response:
> 'Missing }.'
> 
> i've verified that all the files are ok.  what am i missing?

I'm confused about what you're trying to do.  Do you just want to
repalce all instances of 'reqfields' with 'reqinsertfields'?  I think
whats throwing me (and maybe perl) is the '-n' flag on grep.  You are
passing file names to perl whos contents include 'reqfields', but the
'-n' is appending a line number to it which I think ruins the file name
for Perl when it tried to open it.  Try:

   find . -name "*.pm" | xargs perl -pi.bak -e "s/reqfields/reqinsertfields/g;"

and don't worry about the grep;  perl won't do anything if 'reqfields'
isn't in the file.

===

Subject: Re: [sf-perl] inplace editing in 5.6
From: Spencer Thiel <spen@dnai.com>
Date: Wed, 28 Jun 2000 18:50:40 -0700

Try switching the order of commands that you are trying to execute:

find . -name '*.pm' -exec perl -pi.bak -e 's/reqfields/reqinsertfields/g' {} \;

perl does the grep for you through the // (i think)

===

Subject: Re: [sf-perl] inplace editing in 5.6
From: Ian Kallen <spidaman@salon.com>
Date: Wed, 28 Jun 2000 23:40:48 -0700 (PDT)

Today, Spencer Thiel <spen@dnai.com> frothed and gesticulated about Re:...:
> Try switching the order of commands that you are trying to execute:
> 
> find . -name '*.pm' -exec perl -pi.bak -e 's/reqfields/reqinsertfields/g' {} \;
> 
> perl does the grep for you through the // (i think)

No, the reply that just had the file names piping into xargs and perl is
better: it builds an @ARGV for perl and and kicks it off once.  Your
proposal will startup a perl interpretter for every file returned by find!
For command line stuff, xargs is your pal :)

===


the rest of The Pile (a partial mailing list archive)

doom@kzsu.stanford.edu