linux sed 명령 으로 특수 문자 삭제 (사선, 콜론 등 전의 문자 포함)

2063 단어 Linuxshell
간단 한 소개
sed         ,         。
   ,                ,  “    ”(pattern space)。
   sed           ,     ,           。
Sed               ;          ;       。

sed 용법
  sed  ,       ,         。
1、  file     abc     :
    sed '/abc/d' file
    sed '/abc/d' file > output_file
2、  file   ,        ,    “/”
    ,        sed     。
   file   ,  “a/b/Makefile:106:”     。
sed "/a\/b\/Makefile:106: warning:/d" file
  a\ /b ,   “\"     ,"\ /"      ,   “/”  。
  ,“/a\ /b\ /Makefile:106:”,      ,  “a/b/Makefile:106:”

3、  
#cat source_file.txt 
test for sed
a/b/Makefile:106: warning:11111
line3 
a/b/Makefile:106: warning:222222
line5
end
  sed  ,       “a/b/Makefile:106:”     。
#sed "/a\/b\/Makefile:106: warning:/d" source_file.txt 
test for sed
line3 
line5
end
            ,          。
    sed "/a\/b\/Makefile:106: warning:/d" source_file.txt  > output.txt

좋은 웹페이지 즐겨찾기