2019년 1월 22일 화요일

쉘스크립트 문자열 바꾸기


<< test.txt >>
this is an apple.
path=/aa/bb/cc

1. 기본 명령어

cat test.txt | sed -e "s/{TARGET_STRING}/{REPLACE_STRING}/g"

1.1 apple --> orange 로 바꾸기

cat test.txt | sed -e "s/apple/orange/g"

결과

this is an orange.
path=/aa/bb/cc

 1.2 /aa/bb --> local 로 바꾸기

cat test.txt | sed -e "s/\/aa\/bb/local/g"

결과


this is an orange.
path=local/cc

댓글 없음:

댓글 쓰기

추천 게시물

python: SVD(Singular Value Decomposition)로 간단한 추천시스템 만들기( feat. surprise )

svd_example In [15]: # !pip install surprise In [21]: from...