Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

HELP: string length limit in awk

260 views
Skip to first unread message

Jie Yin

unread,
Dec 29, 1997, 3:00:00 AM12/29/97
to

I'm a novice in awk, looking for help to deal with string length limit in
my implementation.

According to The AWK Programming Language, the limit for characters in
literal string should be around 400. But it seems that I can't assign or
print string longer than 148 chars in my implementation, is that normal?

Both { print "...>148 chars.." } and { mystring = "...>148 chars" print
mystring} trigger the error "string too long".

Is there a way to work around it? I need to assing a long paragraph to a
string variable and then print it out somewhere.

Thanks in advance for any hint.

Happy New Year.

Jie

--
==============================================================

\\///// Jie Yin
| = = | Biopsychology, The University of Chicago

Charles Demas

unread,
Dec 29, 1997, 3:00:00 AM12/29/97
to Jie Yin

In article <ELyM3...@midway.uchicago.edu>,

Jie Yin <jie...@midway.uchicago.edu> wrote:
>I'm a novice in awk, looking for help to deal with string length limit in
>my implementation.
>
>According to The AWK Programming Language, the limit for characters in
>literal string should be around 400. But it seems that I can't assign or
>print string longer than 148 chars in my implementation, is that normal?
>
>Both { print "...>148 chars.." } and { mystring = "...>148 chars" print
>mystring} trigger the error "string too long".
>
>Is there a way to work around it? I need to assing a long paragraph to a
>string variable and then print it out somewhere.

Try using gawk, it usually doesn't have length problems. It's
one of those GNU things.

Gawk also has many other features that are not available with awk, such
as more functions. See if it's on your system "man gawk"

or "whereis gawk", and if it isn't ask your sysadmin.

You might also check for/into other variants such as nawk and mawk.

If problems persist, you might break up your large string into separate
shorter strings and then print each one using the printf function,
which doesn't put in a newline until you tell it to.

You could even assign these shorter strings to array elements, then
printf the array elements in a loop.

Why you want to print a line that long is in itself questionable as
most screens and printers are not usually larger than 132 characters
per line, but you may have your reasons.


Chuck Demas
Needham, Mass.

--
Eat Healthy | _ _ | Nothing would be done at all,
Stay Fit | @ @ | If a man waited to do it so well,
Die Anyway | v | That no one could find fault with it.
de...@tiac.net | \___/ | http://www.tiac.net/users/demas

Ian Stirling

unread,
Jan 2, 1998, 3:00:00 AM1/2/98
to

Jie Yin <jie...@midway.uchicago.edu> wrote:
: I'm a novice in awk, looking for help to deal with string length limit in
: my implementation.

: Is there a way to work around it? I need to assing a long paragraph to a


: string variable and then print it out somewhere.

gawk3.0.3
Is the simple answer, download it from your favourite GNU mirror site.
No real limits on lengths of strings/lines/...

--
Ian Stirling. Designing a linux PDA, see http://www.mauve.demon.co.uk/
----- ******* If replying by email, check notices in header ******* -----
"Looks like his brainwaves crash a little short of the beach..." Duckman.


0 new messages