export environment variable from a bash script

February 1st, 2011 mysurface

You may want to create a bash script that export some environment variable for your shell, but infect every execution of bash script is a unique session, where the variable export within it can’t be carry backward back to the bash shell. For example you have a env.sh which contains some environment variables export HELLO=hello […]

Posted in Bash, source | Hits: 204463 | 14 Comments »

config file for your bash script

January 22nd, 2011 mysurface

Sometime you may wish to create a bash script to do something based on a config file, what actually was in your mind? How to implement the config file for your bash script? First I think of using command ‘cut’, where I can create a list of tag=value, then uses ‘cut‘ to read out the […]

Posted in Bash, source | Hits: 177684 | 12 Comments »

sudo is different from su

September 21st, 2006 mysurface

Some of the distro uses sudo to gaim access to run root privilage commands. But some of the distro do not include sudo by default such as FC5. To run some root privilage programs, you need to login as root by using su and gives root password. Sometimes admin would not like to give away […]

Posted in Admin, source, sudo | Hits: 70444 | 2 Comments »


September 14th, 2006 durian

If you have a lot of variables set in a configuration file and you need to access all those variables quickly, you can try to use source filename For example, you have a configuration file named /etc/vars.conf with the following content: VAR1=hkong VAR2=is VAR3=leaving function test1 { echo $VAR3 $VAR2 $VAR1 } You can then […]

Posted in Common, source | Hits: 39864 | 4 Comments »