245 246 DirectoryIndex index.html 247
에서
245 246 DirectoryIndex index.html index.htm index.php 247
으로 문자 치환을 하려하는데 도와주세요 ㅠ
sed '/246/s/\([0-9]*\)[ ]*\(.*\)[ ]*\(index\).html[ ]*/\1 \2 \3.html \3.htm \3.php/'
원본 파일은 그대로 둔채 새파일을 만드는 방법을 파이썬으로 만들어봤씁니다.
# -*- coding: utf-8 -*- f = open("data.txt", "r") data = f.read() data_new = data.replace("246 DirectoryIndex index.html", "246 DirectoryIndex index.html index.htm index.php") with open("data_new.txt", "w") as nf: nf.write(data_new) f.close() </code>
원본 파일을 원본파일.orig 로 백업하고 새파일은 갱신하는 방식으로 다시 썼습니다.
# -*- coding: utf-8 -*- f = open("data.txt", "r") data = f.read() data_new = data.replace("246 DirectoryIndex index.html", "246 DirectoryIndex index.html index.htm index.php") with open("data.txt", "w") as nf: nf.write(data_new) with open("data.txt.orig", "w") as of: of.write(data) f.close()
텍스트 포맷에 대한 자세한 정보
<code>
<blockcode>
<apache>
<applescript>
<autoconf>
<awk>
<bash>
<c>
<cpp>
<css>
<diff>
<drupal5>
<drupal6>
<gdb>
<html>
<html5>
<java>
<javascript>
<ldif>
<lua>
<make>
<mysql>
<perl>
<perl6>
<php>
<pgsql>
<proftpd>
<python>
<reg>
<spec>
<ruby>
<foo>
[foo]
확인無
sed '/246/s/\([0-9]*\)[ ]*\(.*\)[ ]*\(index\).html[ ]*/\1 \2 \3.html \3.htm \3.php/'
곁가지로,,,
원본 파일은 그대로 둔채 새파일을 만드는 방법을 파이썬으로 만들어봤씁니다.
원본 파일을 원본파일.orig 로 백업하고 새파일은
원본 파일을 원본파일.orig 로 백업하고 새파일은 갱신하는 방식으로 다시 썼습니다.
댓글 달기