티스토리 뷰

728x90
${varName//$'\n'/\\n}

echo $LINE | sed -e "s/12345678/${replace}/g"

https://stackoverflow.com/questions/3306007/replace-a-string-in-shell-script-using-a-variable

 

Replace a string in shell script using a variable

I am using the below code for replacing a string inside a shell script. echo $LINE | sed -e 's/12345678/"$replace"/g' but it's getting replaced with $replace instead of the value of that variable.

stackoverflow.com

http://www.kwangsiklee.com/2017/11/%EC%89%98-%EC%8A%A4%ED%81%AC%EB%A6%BD%ED%8A%B8%EC%97%90%EC%84%9C-%EB%AC%B8%EC%9E%90%EC%97%B4-%EC%B9%98%ED%99%98replace-%ED%95%98%EA%B8%B0/

 

쉘 스크립트에서 문자열 치환(replace) 하기

개요 리눅스 쉘에서 사용할 수 있는 간단한 replace 방법에 대해 정리해둔다. 기본 문자열 치환 $ echo ‘ | sed -e “s/kwangsik/gwangsik/g” 특수문자 치환 \를 앞에 붙여준다. $ echo ‘ | sed -e “s/\.\///g”…

www.kwangsiklee.com

https://superuser.com/questions/955935/how-can-i-replace-a-newline-with-its-escape-sequence

 

How can I replace a newline with its escape sequence?

Using sed to make text that contains certain characters suitable for use in string literals is straightforward: sed "s/\\\\/\\\\\\\\/g" sed "s/\\\"/\\\\\\\"/g" But how can I do something similar ...

superuser.com

 

728x90
댓글