Using Config Files

When you have multiple scripts all using similar settings, it becomes convenient to put the common variables in a config file. The best way to to this like so: 

#!/bin/bash

# Detect the paths and load config files
SCRIPT=`readlink -f $0`
FOLDER=`dirname $SCRIPT`
HOME=`dirname $FOLDER`
CONFIG_FILE=$HOME/etc/install.conf
if [[ -f $CONFIG_FILE ]]; then
        . $CONFIG_FILE
fi



An alternative is 

FOLDER=$(cd `dirname $0` && pwd)
Comments