I want to replace the default listening port of httpd to 9090. I can edit the line in httpd.conf file using belowsed -i /^Listen/c\Listen 9090 /etc/httpd/conf/httpd.confBut the line Listen 80may have white space before it.How do I ignore this white space to match this line?
sed : Ignore line starting whitespace for match
linux;sed;regular expression
Change your matching pattern no catch white spaces before liste in the following way:/^\s*Listen/That will include allListen ..    Listen ...and others.