Skip to main content

Shell Script (Reading config file)

In a shell script, we can use while loop for reading configurations. Config file is based on value and corresponding parameter.

script.config file is like:
Value1,Parameter1
Value2,Parameter2

And script is like:
#!/bin/sh
cat script.config | while read line
do
parameter=${line%,*}
value=${line#*,}
echo $parameter
echo $value
done

Comments

Popular posts from this blog

Find and replace with sed command in Linux

Find and replace feature is always handy. It can turn into a torture when it comes to change or delete a simple constant string in a text file. There is a handy tool in linux for doing these kind of tihngs. Actually sed is not a text editor but it is used outside of the text file to make changes.