1756709 Members
2338 Online
108852 Solutions
New Discussion юеВ

Sed Maximum Line Length?

 
SOLVED
Go to solution
Daniel Correa
Advisor

Sed Maximum Line Length?

An application is trying to run a sed command against a one line file with about 80,000 characters. Sed coredumps. Can someone tell me the maximum line length sed will handle? I'm running 11.11 and sed is patched with PHCO_31246.
6 REPLIES 6
James R. Ferguson
Acclaimed Contributor

Re: Sed Maximum Line Length?

Hi Daniel:

I suspect that this is about 2048 characters, although I can't say for sure.

Use Perl --- it doesn't have silly limits. Post your command (that dumps).

Regards!

...JRF...
Tim Nelson
Honored Contributor

Re: Sed Maximum Line Length?

Or use GNU sed with no limits.

http://www.gnu.org/software/sed/manual/sed.html#Limitations

There is a comment on the above limits to..

The posix standard specifies that conforming sed implementations shall support at least 8192 byte line lengths.

Daniel Correa
Advisor

Re: Sed Maximum Line Length?

It seems to fail somewhere between 75k and 80k characters. The command is;

cat $TMP_FILE_1 | sed -e 's/start=//g' -e 's/stop=//g' -e 's/BalancerEnable//g' -e 's/BalancerDisable//g' -e 's/kill+//g' -e 's/msg=AllReference//g' -e 's/msg=Shutdown//g' -e 's/msg=ShutdownCritical//g' > ${AMC_HOME}/work/AmcDmn_${USER}RO_output.xml

James R. Ferguson
Acclaimed Contributor
Solution

Re: Sed Maximum Line Length?

Hi (again) Daniel:

Since you are using simple substitutions, you can easily convert your needs to Perl:

# perl -pe 's/start=//g;s/stop=//g;s/BalancerEnable//g' file

Notice that all I did is use a semicolon to repeat each substitution instead of separate 'sed -e' programs.

If you want to update inplace, making a backup copy of your file do:

# perl -pi.old -e 's/start=//g;s/stop=//g;s/BalancerEnable//g' file

...the original file wikll be preserved as "file.old".

Regards!

...JRF...

Daniel Correa
Advisor

Re: Sed Maximum Line Length?

Thanks James. Will try your perl suggestion.
Daniel Correa
Advisor

Re: Sed Maximum Line Length?

Perl does teh trick.