What is the Maximum number of characters that i can store in a variable?


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users What is the Maximum number of characters that i can store in a variable?
# 1  
Old 07-23-2004
Question What is the Maximum number of characters that i can store in a variable?

Hi,

Can any one tell me, what is the maximum number of characters that can be stored in a variable?

Thanks in Advance,

Shan
# 2  
Old 07-23-2004
Which language?

Which OS?

Which architecture?
# 3  
Old 07-23-2004
sorry, here are the details

Language : Unix (shell script)
OS : UNIX System V Release 4.0 Version 3.0
# 4  
Old 07-23-2004
By character you mean ASCII character?

8 bits or byte can hold 256 possible values (2^8=256)

C char is 1 byte
C undigned char 1 byte
so then...
C short int 2 bytes
C unsigned short int 2 bytes
C (long) int 4 bytes
C float 4 bytes
C double 8 bytes
In Java byte

By character you mean UCS-2?
16 bits
C short int
C int (sometimes)
Java char and Java short int

By character you mean UCS-4
32 bits
C int (usual)
C long int
Java int

64 bits longword or quadword
C long int (on 64 bit machine)
Java long int

Sometimes it depends on your machine

To allocate space to hold 14 int's

int *ip = malloc(14 * sizeof(int));

whould make room for 14 integers depending on your machine.
# 5  
Old 07-23-2004
I know that some commands on some flavours of Unix running on certain architectures may have restrictions (1024 or 2048 chars), but these are imposed by certain commands such as grep and others under those OSes. Most modern *nix shells are fairly flexible, and you can write to arrays, use xargs, and perform other chicanery to get around any limits you encounter. The Korn shell has a limit of 1024 array elements. I'm not aware of any other limits.

Why would you want to store a huge amount of data in a shell variable anyway??

Cheers
ZB
# 6  
Old 07-25-2004
Reason why i need large amount of data on a variable

Thanks for all your valuable suggestions.

I store a list of mail ids in a .lis file and from a shell script i retrieve all the mail ids and put it in a variable by using blankspace as delimiter.

And i export that variable. So, there is another program which makes use of that exported variable to send the e-mail to e-mail addresses stored in that variable.

When i tried with multiple entires, it allows only 512 characters.

Please suggest me if there is any work around.

Thanks and Regards

Shanmugam
# 7  
Old 08-09-2004
How many addresses, if it is less then 1024 you can use a variable array in the Korn shell. You could also have unlimited length on a variable if you use PERL, which is loaded on most unix boxes.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Maximum number from input by user

I am trying to calculate the maximum number from four numbers input by the user. I have the following code, but it does not work. It says there's an error with the last line "done". Any help would be appreciated. max=0 echo "Please enter four numbers: " for i in 1 2 3 4 do read number... (17 Replies)
Discussion started by: itech4814
17 Replies

2. Shell Programming and Scripting

Maximum number of characters in a line.

Hi, Could any one please let me know what is the maximum number of characters that will fit into a single line of a flat file on a unix. Thanks. (1 Reply)
Discussion started by: Shivdatta
1 Replies

3. UNIX for Dummies Questions & Answers

Using GREP/AWK to extract a number and store it as a variable

Hello, I have a question regarding the awk command. Here is the line I need to grep: 1 F= -.13250138E+03 E0= -.13249556E+03 d E =-.174650E-01 mag= 35.2157 Instead of displaying the number in red I would like to store it as a variable such as X. Is there a way to do this? Thanks for any... (3 Replies)
Discussion started by: modey3
3 Replies

4. Shell Programming and Scripting

Capturing a number at the end of line and store it as variable

Hello, Would someone guide me on how to write a shell script the would search for a phone no using at the end text file using sed or awk and store it in a varaible or print it. The text file is in this form text or numbers in first line text or numbers in second line . . . Firsname... (6 Replies)
Discussion started by: amuthiga
6 Replies

5. UNIX for Dummies Questions & Answers

ls - maximum number of files

what is the maximum number ls can list down (6 Replies)
Discussion started by: karnan
6 Replies

6. UNIX for Dummies Questions & Answers

maximum number of arguments

Hi, What is the maximum number of arguments that could be passed to zsh ? To find out that I tried a simple script. And the maximum number of arguments that could be passed turned out to be 23394 #! /bin/zsh arg=1 i=1 subIndex=23000 while do arg=$arg" "$i i=$(($i + 1))... (9 Replies)
Discussion started by: matrixmadhan
9 Replies

7. UNIX and Linux Applications

handling maximum number characters in an input file

Hi, Can anyone help me? An input file has three lines. Each line should only be 2098 as number of characters however line 2 of the input file has more than the maximum number of characters, it exceeded up to 4098. What should I do so that could handle maximum number of characters? that it could... (1 Reply)
Discussion started by: chrysSty
1 Replies

8. Shell Programming and Scripting

Line with maximum no . of characters

Hey , I want to check the row in a file with maximum characters . the output sud contain that row number along with the no of characters. (4 Replies)
Discussion started by: mohapatra
4 Replies

9. UNIX for Advanced & Expert Users

Maximum number of threads per user

Anybody knows how to setup Maximum number of threads per user or some other value on Sun Solaris 8. (1 Reply)
Discussion started by: s_aamir
1 Replies
Login or Register to Ask a Question