sed 명령 소개

838 단어 shellsed
sed 는 스 트림 편집기 입 니 다. 한 번 에 한 줄 을 처리 하고 원본 파일 을 바 꾸 지 않 습 니 다.처 리 된 줄 을 캐 시 영역 (모드 공간) 에 넣 고 처 리 를 마 친 후 화면 에 표시 하고 캐 시 영역 을 옮 겨 마지막 까지 다음 줄 을 계속 처리 합 니 다.
일치 보이 기
sed -n '/sam/p' testfile    #    sam  ,-n        

일치 삭제
sed '3,$d' testfile    #         
sed '/sam/d' testfile    #    sam  

일치 교체
sed -n 's/sam/tom/g' testfile    #  sam tom,  g           
sed -n 's/[0-9][0-9]$/&.00/' test    #   2    22,   22.00,&     22

다 중 편집
sed -e '1,3d' -e 's/sam/tom/g' testfile    #  1-3 ,   

줄 삽입
sed '2 aok' a.txt    # a.txt      ok
sed '2 iok' a.txt    # a.txt      ok
sed '/hello/aok' a.txt    # a.txt hello   ok

좋은 웹페이지 즐겨찾기