Defining common variables across multiple scripts?

前端 未结 2 1673
逝去的感伤
逝去的感伤 2021-01-13 15:32

I have a number of Bash and Perl scripts which are unrelated in functionality, but are related in that they work within the same project. The fact that they work in the same

2条回答
  •  情话喂你
    2021-01-13 16:32

    Define environments variables : user level : in your ~/.profile or ~/.bash_profile or ~/.bash_login or ~/.bashrc system level : in /etc/profile or /etc/bash.bashrc or /etc/environment

    For example add tow lines foreach variable :

    FOO=myvalue
    export FOO 
    

    To read this variable in bash script :

    #! /bin/bash
    
    echo $FOO
    

    in perl script :

    #! /bin/perl
    
    print $ENV{'FOO'};
    

提交回复
热议问题