![Bash를 사용하여 Apache 구성 스크립트 구성](https://linux55.com/image/202262/Bash%EB%A5%BC%20%EC%82%AC%EC%9A%A9%ED%95%98%EC%97%AC%20Apache%20%EA%B5%AC%EC%84%B1%20%EC%8A%A4%ED%81%AC%EB%A6%BD%ED%8A%B8%20%EA%B5%AC%EC%84%B1.png)
들여쓰기가 제대로 되지 않았지만 작동하는 구성 파일(가상 호스트)이 있다고 가정해 보겠습니다 www-example.com.conf
. 예를 들면 다음과 같습니다.
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
ServerName www.example.com
ServerAlias example.com
ServerAdmin [email protected]
DocumentRoot /var/www/example.com/public
DirectoryIndex index.php
<Directory /var/www/example.com/public>
AllowOverride All
Options +FollowSymLinks +Indexes
Order Allow,Deny
Allow from all
</Directory>
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/example-com-error.log
CustomLog ${APACHE_LOG_DIR}/example-com-access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
원하는 출력은 다음과 같습니다.
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
ServerName www.example.com
ServerAlias example.com
ServerAdmin [email protected]
DocumentRoot /var/www/example.com/public
DirectoryIndex index.php
<Directory /var/www/example.com/public>
AllowOverride All
Options +FollowSymLinks +Indexes
Order Allow,Deny
Allow from all
</Directory>
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/example-com-error.log
CustomLog ${APACHE_LOG_DIR}/example-com-access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
tidy
우리는 bash 스크립트에서 이 구성 파일의 들여쓰기를 "" 수정하고 싶습니다 (구성 파일을 손상시키지 않고).
이 작업을 수행하려면 어떤 명령줄 도구를 사용해야 합니까?
나는 시도했다:
xml_pp test.txt
(''>''의 일부로 상단에 ''*:80>''이 있기 때문에 기술적으로 XML이 아니기 때문에 실패합니다)- 사용
tidy