%EB%A5%BC%20%EA%B5%AC%EB%B6%84%20%EA%B8%B0%ED%98%B8%EB%A1%9C%20%EC%82%AC%EC%9A%A9%ED%95%98%EB%8A%94%20%EB%B0%A9%EB%B2%95.png)
저는 sed
이 질문을 자주 사용하지 않아서 질문이 너무 단순했다면 사과드립니다.
다음은 잘 작동합니다.
sed -i '/<\/IfModule>/i TEST' security2.conf
이제 구분 기호로 사용하고 싶습니다 #
. 왜 이것이 작동하지 않습니까?
sed -i '#</IfModule>#i TEST' security2.conf
답변1
sed
(1)의 매뉴얼 페이지는 다음과 같습니다.
/regexp/
정규식과 일치하는 행과 일치합니다regexp
.
\cregexpc
정규식과 일치하는 행과 일치합니다regexp
.c
어떤 문자라도 가능 합니다.
따라서 상황에 따라 , 또는 /regexp/
로 바꿀 수 있습니다 .\#regexp#
sed -i '\#</IfModule>#i TEST' security2.conf
-i
개인적으로 저는 제대로 했다고 확신할 때까지 테스트합니다 .
답변2
#
설명서를 검색해 보면 sed(1)
알 수 있습니다.
[0addr]#
The ``#'' and the remainder of the line are ignored (treated as a
comment), with the single exception that if the first two charac-
ters in the file are ``#n'', the default output is suppressed.
This is the same as specifying the -n option on the command line.
그래서 당신이 쓴 댓글은 코드가 아닙니다.