Luca Luca - 1 year ago 97
Linux Question

BASH exclude specific char from string

I must implement one script, i should get list of virtual hosts apache:

apachectl -S | grep -i site | awk '{print $5}'


Syntax OK

how can i receive this output? (without Syntax OK/()/:*):


Answer Source

With awk setting (, ) and : as field separators, and getting the second field:

awk -F'[():]' '{print $2}'


% awk -F'[():]' '{print $2}' <<<'Syntax OK (/usr/local/apache2/conf/site.conf:1)'
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download