Re: [OT] Collective memory query

2004-10-08 Thread Peter Cordes
On Wed, Sep 29, 2004 at 10:08:28PM +0200, Adrian 'Dagurashibanipal' von Bidder wrote:
> On Tuesday 28 September 2004 15.49, Bartosz Fenski aka fEnIo wrote:
> > On Mon, Sep 27, 2004 at 06:38:03PM +0200, Adrian 'Dagurashibanipal' von 
> Bidder wrote:
> > > > for foo in `find . -name "something"`
> > >
> > > Note that
> > > $ for foo in `command outputting a list of filenames`
> > >
> > > should *always* be replaced by
> > >
> > > $ said command | while read foo; do ...
> [...]
> > So what is the magic barrier when this should stop working?
> > I'm just curious.
> 
> 
> Hmm. I can't comment on that specifically, for current versions of some 
> shells. I know I have seen 'command line too long' messages in the past 
> when using `find ...` constructs, and I bet that on busybox based resscue 
> disks and other restricted shells this topic will still be relevant.

 The "line too long" limit applies when trying to execve(2) anything.
There's a limit there.  For shell built-ins, there doesn't have to be a
limit, but as you point out, busybox might have one.

> In any case, using the while loop will pipeline the operations so you get 
> full benefit from multitasking.

 Yeah, that's an elegant idiom.  I'll have to remember to use it in the
future. :)

-- 
#define X(x,y) x##y
Peter Cordes ;  e-mail: X([EMAIL PROTECTED] , des.ca)

"The gods confound the man who first found out how to distinguish the hours!
 Confound him, too, who in this place set up a sundial, to cut and hack
 my day so wretchedly into small pieces!" -- Plautus, 200 BC


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]



Re: [OT] Collective memory query

2004-09-29 Thread Adrian 'Dagurashibanipal' von Bidder
On Tuesday 28 September 2004 15.49, Bartosz Fenski aka fEnIo wrote:
> On Mon, Sep 27, 2004 at 06:38:03PM +0200, Adrian 'Dagurashibanipal' von 
Bidder wrote:
> > > for foo in `find . -name "something"`
> >
> > Note that
> > $ for foo in `command outputting a list of filenames`
> >
> > should *always* be replaced by
> >
> > $ said command | while read foo; do ...
[...]
> So what is the magic barrier when this should stop working?
> I'm just curious.


Hmm. I can't comment on that specifically, for current versions of some 
shells. I know I have seen 'command line too long' messages in the past 
when using `find ...` constructs, and I bet that on busybox based resscue 
disks and other restricted shells this topic will still be relevant.

In any case, using the while loop will pipeline the operations so you get 
full benefit from multitasking.

greetings
-- vbi

-- 
Beware of the FUD - know your enemies. This week
* The Alexis de Toqueville Institue *
http://fortytwo.ch/opinion/


pgpmXk5scEIfr.pgp
Description: PGP signature


Re: [OT] Collective memory query

2004-09-28 Thread Bartosz Fenski aka fEnIo
On Mon, Sep 27, 2004 at 06:38:03PM +0200, Adrian 'Dagurashibanipal' von Bidder wrote:
> > for foo in `find . -name "something"`
> 
> Note that 
> $ for foo in `command outputting a list of filenames`
> 
> should *always* be replaced by
> 
> $ said command | while read foo; do ...
> 
> (Or, for trivial cases, xargs) because the for loop will not work with more 
> than a few hundred files.

What does exacly "more than a few hundred files" mean?

for i in `ls -R /usr/`; do echo $i; done

Works fine both in bash and zsh.

([EMAIL PROTECTED])~$for i in `ls -R /usr/`; do echo $i; done | wc -l 
103464
([EMAIL PROTECTED])~$

So what is the magic barrier when this should stop working?
I'm just curious.

regards
fEnIo

-- 
  _  Bartosz Fenski | mailto:[EMAIL PROTECTED] | pgp:0x13fefc40 | IRC:fEnIo
_|_|_ 32-050 Skawina - Glowackiego 3/15 - w. malopolskie - Polska
(0 0)  phone:+48602383548 | Slackware - the weakest link
ooO--(_)--Ooo  http://skawina.eu.org | JID:[EMAIL PROTECTED] | RLU:172001


signature.asc
Description: Digital signature


Re: [OT] Collective memory query

2004-09-27 Thread Bernd Eckenfels
In article <[EMAIL PROTECTED]> you wrote:
> Last time I read the xargs documentation it stated that using '\0' as an
> input separator would also tell it to pass at most one argument to the
> command.

> echo -en "a\0b\0c" | xargs -t -0 echo
echo a b c
a b c
> echo -en "a\0b\0c" | xargs -t -s 8 -0 echo
echo a
a
echo b
b
echo c
c

looks like it has changed, the default is to fill up the command line even
with the -0 arg, unless maxline length is specified.

Greetings
Bernd
-- 
eckes privat - http://www.eckes.org/
Project Freefire - http://www.freefire.org/


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]



Re: [OT] Collective memory query

2004-09-27 Thread Daniel Pittman
On 28 Sep 2004, Bernd Eckenfels wrote:
> In article <[EMAIL PROTECTED]> you wrote:
>> Alternately, with sed:
>>
>> ] sed -si.orig -e '...' `find . -name '...'`
>>
>> More safely, but with more forks:
>>
>> ] find . -name '...' -print0 | xargs -0 sed -si.orig -e '...'
>
> BTW: I dont see how xarg would do more forks than the shell? Because the
> above version will fork once or not at all (if argument list is too long)
> and the below solution will fork as much as needed (which is once in cae the
> list fits into the command line). So xargs only forks one more than the
> backtick version.

Last time I read the xargs documentation it stated that using '\0' as an
input separator would also tell it to pass at most one argument to the
command.

Perhaps this has changed in the intervening years, since I didn't check
that recently.

Regards,
Daniel
-- 
The truth knocks on the door and you say, 'Go away, I'm looking for
the truth,' and so it goes away. Puzzling...
-- Robert Pirsig


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]



Re: [OT] Collective memory query

2004-09-27 Thread Bernd Eckenfels
In article <[EMAIL PROTECTED]> you wrote:
> Alternately, with sed:
> 
> ] sed -si.orig -e '...' `find . -name '...'`
> 
> More safely, but with more forks:
> 
> ] find . -name '...' -print0 | xargs -0 sed -si.orig -e '...'

BTW: I dont see how xarg would do more forks than the shell? Because the
above version will fork once or not at all (if argument list is too long)
and the below solution will fork as much as needed (which is once in cae the
list fits into the command line). So xargs only forks one more than the
backtick version.

Greetings
Bernd
-- 
eckes privat - http://www.eckes.org/
Project Freefire - http://www.freefire.org/


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]



Re: [OT] Collective memory query

2004-09-27 Thread Mason Loring Bliss
On Mon, Sep 27, 2004 at 06:38:03PM +0200, Adrian 'Dagurashibanipal' von Bidder wrote:

> $ for foo in `command outputting a list of filenames`
> 
> should *always* be replaced by
> 
> $ said command | while read foo; do ...

Hm. I like that better in general. Processing doesn't have to wait for the
entirety of the command's output to be generated.

Thanks.

-- 
Mason Loring Bliss  [EMAIL PROTECTED]  They also surf who
awake ? sleep : dream; https://bliss.dyndns.org/only stand on waves.


pgpRaVn1z6YJA.pgp
Description: PGP signature


Re: [OT] Collective memory query

2004-09-27 Thread Adrian 'Dagurashibanipal' von Bidder
On Monday 27 September 2004 16.28, Mason Loring Bliss wrote:
>
> for foo in `find . -name "something"`

Note that 
$ for foo in `command outputting a list of filenames`

should *always* be replaced by

$ said command | while read foo; do ...

(Or, for trivial cases, xargs) because the for loop will not work with more 
than a few hundred files.


greetings
-- vbi


-- 
Beware of the FUD - know your enemies. This week
* Patent Law, and how it is currently abused. *
http://fortytwo.ch/


pgpsDpOWzKgsc.pgp
Description: PGP signature


Re: [OT] Collective memory query

2004-09-27 Thread Mason Loring Bliss
On Mon, Sep 27, 2004 at 12:48:03PM +0100, Dale Amon wrote:

> A couple years ago I ran across a sed like program
> that will recursively descend through a tree and apply
> specified edits in place. I have searched my notes,
> gone through the deb available and have not been able
> to find it. Might just have been something on
> SourceForge...
> 
> Has anyone else run across a program of this nature?

My favourite method:

for foo in `find . -name "something"`
do
ed $foo << END
,s/something/else/g
w
q
END
done

This is doubtless less efficient than having find(1) drive ed directly.
It has the advantage, however, of working everywhere consistently without
requiring some new sed(1) or Perl or the like.

-- 
Mason Loring Bliss   [EMAIL PROTECTED]   Oderint dum metuant!
https://bliss.dyndns.org/awake ? sleep : random() & 2 ? dream : sleep;


pgpiWb82ywjP4.pgp
Description: PGP signature


Re: [OT] Collective memory query

2004-09-27 Thread Daniel Pittman
On 27 Sep 2004, Dale Amon wrote:
> A couple years ago I ran across a sed like program that will
> recursively descend through a tree and apply specified edits in place.
> I have searched my notes, gone through the deb available and have not
> been able to find it. Might just have been something on SourceForge...
>
> Has anyone else run across a program of this nature?

I don't recall any specific program like that, but wouldn't this do just
fine?

] find . -name '...' -print0 | perl -0pi.orig -e 's/foo/bar/gi'

That will recurse over files, editing them in place using Perl.

Alternately, with sed:

] sed -si.orig -e '...' `find . -name '...'`

More safely, but with more forks:

] find . -name '...' -print0 | xargs -0 sed -si.orig -e '...'

Wrapping your own shell script around that should be trivial.

Daniel
-- 
Men love to wonder, and that is the seed of our science.
-- Ralph Waldo Emerson, _Society and Solitude_



Re: [OT] Collective memory query

2004-09-27 Thread Bartosz Fenski aka fEnIo
On Mon, Sep 27, 2004 at 01:07:40PM +0100, Simon Huggins wrote:
> On Mon, Sep 27, 2004 at 12:48:03PM +0100, Dale Amon wrote:
> > A couple years ago I ran across a sed like program
> > that will recursively descend through a tree and apply
> > specified edits in place.
> > Has anyone else run across a program of this nature?
> 
> This is probably more appropriate for -user but did you mean perl -pi?
> 
> e.g. find some_dir -type f|xargs perl -pi -e 's/foo/bar/; s/wibble/wobble/'

find some_dir -type f | xargs sed -i -e 's/foo/bar/' -e 's/wibble/wobble/'

Should work fine with more recent seds (sarge/sid has proper version).

regards
fEnIo


-- 
  _  Bartosz Fenski | mailto:[EMAIL PROTECTED] | pgp:0x13fefc40 | 
IRC:fEnIo
_|_|_ 32-050 Skawina - Glowackiego 3/15 - w. malopolskie - Polska
(0 0)  phone:+48602383548 | Slackware - the weakest link
ooO--(_)--Ooo  http://skawina.eu.org | JID:[EMAIL PROTECTED] | RLU:172001


signature.asc
Description: Digital signature


Re: [OT] Collective memory query

2004-09-27 Thread Dale Amon
On Mon, Sep 27, 2004 at 10:04:00PM +1000, Andrew McGlashan wrote:
> Try again:
> http://packages.debian.org/testing/utils/rpl
> "Intelligent recursive search/replace utility"

Thanks much. I do believe that is the one. 

*amon runs off to dselect yet again...

-- 
--
   Dale Amon [EMAIL PROTECTED]+44-7802-188325
   International linux systems consultancy
 Hardware & software system design, security
and networking, systems programming and Admin
  "Have Laptop, Will Travel"
--


signature.asc
Description: Digital signature


Re: [OT] Collective memory query

2004-09-27 Thread Brett Parker
On Mon, Sep 27, 2004 at 12:48:03PM +0100, Dale Amon wrote:
> A couple years ago I ran across a sed like program
> that will recursively descend through a tree and apply
> specified edits in place. I have searched my notes,
> gone through the deb available and have not been able
> to find it. Might just have been something on
> SourceForge...

I'd use find . -type f | xargs perl -pi -e 'someregularexpression'

so, for example, to change all foo to bar:
find . -type f | xargs perl -pi -e 's/foo/bar/g;'

Hope that helps,

Cheers,
-- 
Brett Parker
web:   http://www.sommitrealweird.co.uk/
email: [EMAIL PROTECTED]



Re: [OT] Collective memory query

2004-09-27 Thread Andrew McGlashan

Try again:
http://packages.debian.org/testing/utils/rpl
"Intelligent recursive search/replace utility"

Regards

AndrewM

Andrew McGlashan
ADSL, Dialup, Satellite, ISDN and other enquiries: 1300 85 3804

Mobile: 04 2574 1827 Fax: 03 8790 1224

Affinity Vision Australia Pty Ltd
www.affinityvision.com.au
www.affinityvision.net/adsl/



Re: [OT] Collective memory query

2004-09-27 Thread Andrew McGlashan

Sorry wrong link... I didn't look closely at it.  Ughh.

Andrew McGlashan wrote:

Does this resemble what you want?
http://www.cs.rit.edu/~hpb/Man/_Man_Local_html/html1/srwin.1.html

Regards

AndrewM

Andrew McGlashan
ADSL, Dialup, Satellite, ISDN and other enquiries: 1300 85 3804

Mobile: 04 2574 1827 Fax: 03 8790 1224

Affinity Vision Australia Pty Ltd
www.affinityvision.com.au
www.affinityvision.net/adsl/

- Original Message -
From: "Dale Amon" <[EMAIL PROTECTED]>
To: 
Sent: Monday, September 27, 2004 9:48 PM
Subject: [OT] Collective memory query


AndrewM

Andrew McGlashan
ADSL, Dialup, Satellite, ISDN and other enquiries: 1300 85 3804

Mobile: 04 2574 1827 Fax: 03 8790 1224

Affinity Vision Australia Pty Ltd
www.affinityvision.com.au
www.affinityvision.net/adsl/



Re: [OT] Collective memory query

2004-09-27 Thread Andrew McGlashan

Does this resemble what you want?
http://www.cs.rit.edu/~hpb/Man/_Man_Local_html/html1/srwin.1.html

Regards

AndrewM

Andrew McGlashan
ADSL, Dialup, Satellite, ISDN and other enquiries: 1300 85 3804

Mobile: 04 2574 1827 Fax: 03 8790 1224

Affinity Vision Australia Pty Ltd
www.affinityvision.com.au
www.affinityvision.net/adsl/

- Original Message - 
From: "Dale Amon" <[EMAIL PROTECTED]>

To: 
Sent: Monday, September 27, 2004 9:48 PM
Subject: [OT] Collective memory query




Re: [OT] Collective memory query

2004-09-27 Thread Simon Huggins
On Mon, Sep 27, 2004 at 12:48:03PM +0100, Dale Amon wrote:
> A couple years ago I ran across a sed like program
> that will recursively descend through a tree and apply
> specified edits in place.
> Has anyone else run across a program of this nature?

This is probably more appropriate for -user but did you mean perl -pi?

e.g. find some_dir -type f|xargs perl -pi -e 's/foo/bar/; s/wibble/wobble/'

Simon.

-- 
[ "Fun, fun, fun, in the sun, sun, sun..." ]
Black Cat Networks.  http://www.blackcatnetworks.co.uk/


pgpolCRhkZH7v.pgp
Description: PGP signature