Re: Maximum size of Pattern space / Hold space

Mark Edgar <[email protected]>
Newsgroups gmane.editors.sed.user
Message-ID <CABHMh_07xLhuRM3sVQky3YnejtS2OHwQyw1R-b4yfqpeC+omXg@mail.gmail.com>
On Tue, Apr 3, 2012 at 2:15 AM, JDF <[email protected]> wrote:
> I am using GNU sed 4.2.1 on Fedora 14.
> Does anyone know what the maximum size of the Pattern/Hold spaces
> can be?

They seem to be resizable buffers:
http://git.savannah.gnu.org/cgit/sed.git/tree/sed/execute.c?id=4.2

> If I did many, many N or H commands, could I overflow them?

How many is "many, many"?  What do you mean by "overflow"?  If you
append enough, you will of course eventually run out of memory:

$ yes {0..7}\ {a..p} | head -n 262145 | (ulimit -v 100000; sed -e :1
-e H -e n) | wc -l
sed: couldn't re-allocate memory
262144

     -Mark
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.