![grep, sed 또는 awk를 사용하여 컬 출력에서 특수 문자를 제거하는 방법](https://linux55.com/image/128678/grep%2C%20sed%20%EB%98%90%EB%8A%94%20awk%EB%A5%BC%20%EC%82%AC%EC%9A%A9%ED%95%98%EC%97%AC%20%EC%BB%AC%20%EC%B6%9C%EB%A0%A5%EC%97%90%EC%84%9C%20%E2%80%8B%E2%80%8B%ED%8A%B9%EC%88%98%20%EB%AC%B8%EC%9E%90%EB%A5%BC%20%EC%A0%9C%EA%B1%B0%ED%95%98%EB%8A%94%20%EB%B0%A9%EB%B2%95.png)
\r\n
컬 출력에서 제거 하려는 코드는 다음과 같습니다.
curl -s -u ian.guinto:W0lfg@ng131994 --request GET --url 'https://jira.toro.io/rest/api/2/issue/OJTSYSAD-829/comment' -H "Content-Type: application/json" | jsonpp | grep body | cut -d ':' -f2
출력됩니다.
"Test comment",
"test comment 2\r\n",
"test comment3\r\nTest comment 4\r\n",
내 예상 결과는 다음과 같습니다
"Test comment",
"test comment 2",
"test comment3 Test comment 4",
답변1
실제로 JQ를 사용하여 이 작업을 수행할 수 있습니다.
$ curl -L -O -u ian.guinto:W0lfg@ng131994 \
jira.toro.io/rest/api/2/issue/OJTSYSAD-829/comment
$ jq '.comments[].body | rtrimstr("\r\n") | gsub("\r\n"; " ")' comment
"Test comment"
"test comment 2"
"test comment3 Test comment 4"