본문 바로가기

리눅스

[리눅스] sed 명령어

728x90

sed 명령어

공백문자 파이프라인으로 치환

sed -i "s/[[:space:]]/|/g" 1.tlb
sed -r "s/\s+/\|/g" 1.tlb > 1.tmp

![:alnum:] ![a-z A-Z 0-9], 모든 알파벳 문자와 숫자
![:alpha:] ![a-z A-Z], 모든 알파벳 문자
![:blank:] 스페이스 문자와 탭문자
![:cntrl:] 모든 컨트롤 문자들
![:digit:] 숫자, ![0-9]
![:graph:] 모든 visible 문자들
![:lower:] 알파벳 소문자, ![a-z]
![:print:] Non-control 문자
![:space:] 공백문자
![:upper:] 알파벳 대문자, ![A-Z]
![:xdigit:] 16진수 문자![0-9 a-f A-F]


'IfModule mime_module.*' 문자열 검색 후 'AddType application/x-httpd-php-source .phps' 추가

sed -i 's,\(IfModule mime_module.*\),\1\n\tAddType application/x-httpd-php-source .phps,g;' /usr/local/apache2/conf/httpd.conf

sed -i 's,\(IfModule mime_module.*\),\1\n\tAddType application/x-httpd-php .htm .html .php .ph .phtml .inc,g;' /usr/local/apache2/conf/httpd.conf
sed -i 's,\(IfModule mime_module.*\),\1\n\tAddType application/x-httpd-php-source .phps,g;' /usr/local/apache2/conf/httpd.conf
$ cat /usr/local/apache2/conf/httpd.conf
<IfModule mime_module>
        AddType application/x-httpd-php-source .phps
        AddType application/x-httpd-php .htm .html .php .ph .phtml .inc
    #
    # TypesConfig points to the file containing the list of mappings from
    # filename extension to MIME-type.
    ...

 

sed -i 's/^\(dir .*\)$/# \1\ndir \/data/' /etc/redis/redis.conf

 

sed -i.backfile -re "s/^(mirrorlist(.*))/#\1/g" CentOS-Base.repo
sed -i.backfile -re "s/^#baseurl/baseurl/g" CentOS-Base.repo
sed -i.backfile -re "s/http:\/\/mirror.centos.org/https:\/\/mirror.kakao.com/g" CentOS-Base.repo
728x90