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

Maximum variable length in ksh

661 views
Skip to first unread message

JWR

unread,
Jun 9, 2003, 8:02:01 AM6/9/03
to
Can anyone suggest what the maximum number of characters you can
assign to a variable (including previously assigned variables), and
also if there is a limit to the number of variables that can be
assigned in one script/programme?

For example:

a=(first character - last character) <-- how many characters could
this be?

b=(first variable - last variable) <-- how many variables could this
be?

We're looking at this under 5.0.5 and ksh

TY

Bob Stockler

unread,
Jun 9, 2003, 10:52:45 AM6/9/03
to SCO Miscellaneous
On Mon, Jun 09, 2003 at 05:02:01AM -0700, JWR wrote:
|
| Can anyone suggest what the maximum number of characters you can
| assign to a variable (including previously assigned variables), and
| also if there is a limit to the number of variables that can be
| assigned in one script/programme?
|
| For example:
|
| a=(first character - last character) <-- how many characters could
| this be?

In ksh on SCO OSR 5.0.5 I executed:

~tmp: a=$(</usr/dict/words)
~tmp: echo ${#a}
194185

I continued by setting a="$a$a$a$a" or a="$a$a" until the
length of the value held in "a" was 3106960, and quit.

You can carry that farther if you want to know the absolute
limit.

| b=(first variable - last variable) <-- how many variables could this
| be?

I don't understand this part of your question.

| We're looking at this under 5.0.5 and ksh

--
Bob Stockler - b...@trebor.iglou.com
Author: MENU EDIT II - The BEST Creator/Editor/Manager for filePro User Menus.
Fully functional (time-limited) demos available by email request (specify OS).

John DuBois

unread,
Jun 9, 2003, 3:19:15 PM6/9/03
to
In article <d68e2226.03060...@posting.google.com>,

JWR <no_spam...@lycos.co.uk> wrote:
>Can anyone suggest what the maximum number of characters you can
>assign to a variable (including previously assigned variables), and
>also if there is a limit to the number of variables that can be
>assigned in one script/programme?
>
>For example:
>
>a=(first character - last character) <-- how many characters could
>this be?

A lot. I just did this:

# ulimit -v 2000000
# j=$(dd bs=1024k count=512 if=/dev/byte/ascii/a)
512+0 records in
512+0 records out
# echo ${#j}
536870912

That's a half gigabyte. I tried the same thing with a gigabyte and got a
memory fault. I tried the same thing in ksh93 and it told me it was out
of memory; ksh88 probably encountered the same problem but didn't catch
it and so faulted. I'd guess that ksh needs two or more times the space
used by variable text at some point during processing of the assignment
(though possibly only for command line substitution as above).

>b=(first variable - last variable) <-- how many variables could this be?

I don't think there's a limit on this.

John
--
John DuBois spc...@armory.com KC6QKZ/AE http://www.armory.com/~spcecdt/

JWR

unread,
Jun 10, 2003, 8:20:04 AM6/10/03
to
spc...@deeptht.armory.com (John DuBois) wrote in message news:<3ee4ddb2$0$1096$8ee...@newsreader.tycho.net>...

Ok, some clarification here. If I login and do:

# set | wc -l
52

I know I have 52 variables set already or just 'set' to show them all.
This is the limit I'm trying to establish. Maybe there's a default
limit and if so can we adjust it?

0 new messages