how to find -l or --log-file string in a file and store absolute path passed with that as a variable ?
Sample file 1:-
$ cat server.log
server_options='-l /tmp/server_log'
Sample file 2:-
$ cat server.log
server_options='--log-file=/tmp/server1_log'
Requirement
if -l or --log-file is found in server_options variable then find the absolute path of the file and store it in a variable
Note:- 1. Don't consider lines starting with "#" 2. if "-l" option is specified between the -l and absolute path there will be a space and if "--log-file" is specified between the "--log-file" and absolute path there will be a equal to sign "="
for example
server_options='-l /tmp/server_log'
server_options='--log-file=/tmp/server1_log'
Desired output of the sample 1 file stored in a variable "LOG_FILE"
$ echo $LOG_FILE
/tmp/server_log
Desired output of the sample 2 file stored in a variable "LOG_FILE"
$ echo $LOG_FILE
/tmp/server1_log
Tried:-
$ grep "^[^#;]" server.log | awk '/\-\l|/{ print $2 }'
/tmp/server_log'
Need more reliable way to achieve this