Most of the time bash script need user input values to generate the data that is presented to user. There are many ways to accept user data in bash like reading data interactively, getting from parameters etc. But there are some situations where bash always need a set of data to generate the output. It will be a burden on the user to input the same data again and again, each time he executes the script. In that situations, storing the value in a configuration file will help. That file can be edited by user, if he requires to pass another set of data. You can see this concept in the BSD style init scripts, were boot parameters are stored in a centralized file like rc.conf.
Today I faced a problem with the script in which I was trying to produce colorized output based on the user preferences. It is unnecessary to ask user each time for his color preference. Instead of that he can just put the input in a configuration file and ask the script to read it. Another option is to hard code the color values in the script itself, but that will make it difficult for the user, if he want to change the color preference later. Continue reading →