![tr은 공백을 바꾸지 않고 문자를 제거합니다.](https://linux55.com/image/208525/tr%EC%9D%80%20%EA%B3%B5%EB%B0%B1%EC%9D%84%20%EB%B0%94%EA%BE%B8%EC%A7%80%20%EC%95%8A%EA%B3%A0%20%EB%AC%B8%EC%9E%90%EB%A5%BC%20%EC%A0%9C%EA%B1%B0%ED%95%A9%EB%8B%88%EB%8B%A4..png)
(사이에 공백 포함) 만 갖도록 수정 animal: dog
하고 싶은 문자열이 있습니다 .tr
animal dog
예를 들어:
echo 'animal: dog' | tr ':' ' '
animal dog
위에 2칸이 있습니다.
빈 문자열로 바꾸려고 시도했지만 다음과 같습니다.
echo 'animal: dog' | tr ':' ''
tr: when not truncating set1, string2 must be non-empty
-s를 사용하면 원하는 결과를 얻을 수 있는데, 그러면 tr을 두 번 호출해야 합니다. 한 사람이 할 수 있는 방법이 있나요?
echo 'animal: dog' | tr ':' ' ' | tr -s ' '
animal dog
답변1
options.outputs 를 사용하세요 -d
.echo animal: dog | tr -d :
animal dog