How to create a new environment variable in UNIX…?

前端 未结 3 1942
深忆病人
深忆病人 2021-02-06 04:40

How to create a new environment variable in unix and use it in a program??????

3条回答
  •  暖寄归人
    2021-02-06 05:23

    Depends on the shell. In bash, you can use:

    export myvar=xyz
    

    which will set the variable and make it available to other programs.

    If you want to set it for one invocation of a program, you can use:

    myvar=xyz ./myprog
    

    This will have it set for the myprog process but not after it exits.

提交回复
热议问题