I have a file that looks like this:
odule(load="imfile" PollingInterval="10")
$MaxMessageSize 65536
#RSYSLOG_ForwardFormat template is used to enable millisecond-accuracy
$ActionForwardDefaultTemplate RSYSLOG_ForwardFormat
module(load="imudp")
input(type="imudp" port="5140")
mail.info stop
# This is rule for filtering apache logs
:msg, regex, ".*DHCP.*" stop
:msg, regex, ".*HTTP/1.1\" 200 [0-9-]* \"-\" \"ClusterListener/1.0\".*" stop
global(
workDirectory="/var/lib/rsyslog" # Directory where queue files will be stored
)
I want to extract the value of port (which is 5140) and store it in an environment variable.
I have tried using variations of awk, grep, and cat commands to try and achieve this but none seem to give me the desired output.
For example, sed -n 's/port=\(.*\)/\1/p' < file.conf gives the following:
input(type="imudp" "5140")
Which is not what I want. I simply want to store 5140 into an environment variable.
Can anyone help with this?