From: Keith MARSHALL <keith.marshall@to...> - 2004-08-16 10:04:34
>> I have a sequence of sed scripts of the form
>> sed 'EXPR' input | \
>> sed 'EXPR1' | \
>> sed 'EXPR2' | \
>> (up to about 15-20 sed programs)
>> for some processing that I need. However, I run into a problem
>> where it seems that make freezes when I execute that command from
>> make. It seems to work fine until I start making the list of
>> connected sed scripts long. I've run into this problem twice now.
>> How should I best resolve this problem? Is there a better way to
>> use sed than what I'm using? Thanks.
> On **IX there should be no problem at all.
> Under Win32 or more precisely using cmd.exe you'll have a limit.
> I don't know what it is but something around 2000 chars IIRC.
> Note that even sh.exe has a limit but that's usually somewhere
> around 32k.
Another possibility -- is there a limit on the number of commands
in a pipeline? MS-DOS used to run into limits with the number of
available system file handles (besides having a ridiculous 127 char
limit on the command line anyway). I'm sure these limits have been
increased in Win32, (the command line limit certainly has -- IIRC
it is 2048 chars in cmd.exe), so may no longer present a problem,
You could try rewriting your 15..20 sed commands as *one*:
sed -e 'EXPR1' \
-e 'EXPR2' \
-e 'EXPR3' \
-e 'EXPRn' \
Or list the expressions in a sed script, as Michael suggests, and
sed -f script.sed input
I tend to use the former style, and have never run into any problem
on Win2K -- using MSYS' sh.exe and make -- even with some fairly
long expression lists, and makefile rules expanding command lines to
six or seven lines, in a 200 char wide console window.
BTW, IIRC *both* GNU/Linux and Solaris have a command line limit of
8192 chars -- I doubt that MSYS' sh.exe achieves the 32k Michael
suggests (but, of course, I may be wrong -- I often am, when I don't
have the time to search for a definitive answer :-)