Hi
I want to create a configuration file from a template one.
The only thing to change for now is the port number that I need to take from another file that has this format:
server:port
So I need to take the 2nd field.
server is passed in the script argument.
how to do that? I think of sed to search the file and get the port then find the line
Listen 80
to
Listen <port>
and then saves a new config file.
thanks for your help.
zaxxon
2
If you are sure it is always starting with the first character being the large 'L' and only 1 blank between "Listen" and "80" you can use this:
sed 's/^Listen 80/Listen \<Port\>/g' infile > httpd.conf.new
If you are unsure and want to get most possibilities taken into account (occurences of blanks and tabs etc.) you might use:
sed 's/^[<space>|<tab>]*Listen[<space>|<tab>]*80/Listen \<Port\>/g' infile > httpd.conf.new