How to read parameters from a file in bash?
Posted on 2007-08-04
I have the following unix bash script. I have the following lines. As you can see I am processing a text file and replacing IP addresses with a hostname. What I would like todo is have a simple parameter file that I can edit and have a shell script to process this.
sed -r 's/(.*192\.168\.1\.99.*)( - )(.*)/\1\ XP1 \3/g' -i access.log
sed -r 's/(.*192\.168\.1\.100.*)( - )(.*)/\1\ XP2 \3/g' -i access.log
So taking the example above it would have a format like:
Ok given this how would I write a shell script to do the following:
1. Open the data file above,
2. Decode the data and build it to a command line that would be able to pass the lines to sed.
Ideally I am looking toget the whole script todo the following. Will reward maximun points for a working script.