user2211264
user2211264

Reputation: 11

Maximum size of enviornment/path variable in unix

I am working on a requirement where I am assigning multiple paths to environment variable in unix for searching in different directories. as below.

export TB_SCC= .:/users/e649744/WTEST/AB:/users/e649744/WTEST/BC:/users/e649744/WTEST/CD:/users/e649744/WTEST/BC:/users/e649744/WTEST/DE:/users/e649744/WTEST/EF:/users/e649744/WTEST/FG:/users/e649744/WTEST/GH:/users/e649744/WTEST/HI:/users/e649744/WTEST/JK:/users/e649744/WTEST/LM

So is there a size limit/restriction for environment variable in unix? IS there a fixed limit after which it will not accept the value?

Please help.

Upvotes: 1

Views: 79

Answers (1)

miku
miku

Reputation: 188114

Try getconf:

$ getconf ARG_MAX

ARG_MAX: Maximum length, in bytes, of the arguments for one of the exec subroutines, including environment data.

On my machine this currently yields 2MB, probably more than enough for most cases:

2097152

See also: getconf Command

Upvotes: 1

Related Questions