And doesn’t this secretly generate a tempfile in the process?
Could the OP be looking for something like mmap? (see RAA)
Regards,
Dan
···
-----Original Message-----
From: Tim Hammerquist [mailto:tim@vegeta.ath.cx]
In Ruby, I could do the same thing, slurp the file into a
string and then
write it back again. I was wondering if there’s a more
idiomatic way of
doing it, in place, i.e., edit the file straight away.
This could probably
be more practical when the file to be edited is a huge one…
Any pointers(sic)…
% ruby -i~ -pe ‘gsub(/pattern/, “replace”)’ myfile
Does this work if /pattern/ spans lines?
Tim Hammerquist
It does generate a secret tempfile, but the original poster MIGHT
just have wanted to not have to create one himself and be responsible
for cleaning it up, which this does.
···
— “Berger, Daniel” djberge@qwest.com wrote:
-----Original Message-----
From: Tim Hammerquist [mailto:tim@vegeta.ath.cx]
In Ruby, I could do the same thing, slurp the file into a
string and then
write it back again. I was wondering if there’s a more
idiomatic way of
doing it, in place, i.e., edit the file straight away.
This could probably
be more practical when the file to be edited is a huge one…
Any pointers(sic)…
% ruby -i~ -pe ‘gsub(/pattern/, “replace”)’ myfile
Does this work if /pattern/ spans lines?
Tim Hammerquist
And doesn’t this secretly generate a tempfile in the process?
Could the OP be looking for something like mmap? (see RAA)
=====
Use your computer to help find a cure for cancer: http://members.ud.com/projects/cancer/
Yahoo IM: michael_s_campbell
Do You Yahoo!?
Yahoo! Finance - Get real-time stock quotes
http://finance.yahoo.com