쉘은 슬래시를 백슬래시로 대체합니다.

쉘은 슬래시를 백슬래시로 대체합니다.

질문이 있습니다. 슬래시를 백슬래시로 바꾸는 방법은 무엇입니까?

문자열이 있습니다.

App/Models

나는해야한다

App\Models

매우 감사합니다

답변1

이것을 시도해 보세요(예 bash: ).

string="App/Models"
echo "${string//\//\\}"

또는 변수로 사용하지 않는 경우 다음을 사용할 수 있습니다 tr.

printf '%s\n' "App/Models" | tr '/' '\'

답변2

$ printf '%s\n' "App/Models" | sed -e 's|/|\\|g'
App\Models

관련 정보