I'm trying to remove \r\n in the output of my curl my code is:

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 

that will output.

 "Test comment",
 "test comment 2\r\n",
 "test comment3\r\nTest comment 4\r\n",

my expect out put is:

 "Test comment",
 "test comment 2",
 "test comment3 Test comment 4",
  • it would help if you post output of grep body... you can use sed/awk to remove \r\n – Sundeep Mar 2 '18 at 3:36
  • I've tried sed 's/\r\n//g' – Ian Jaylo Guinto Mar 2 '18 at 3:43
  • try sed 's/\\r\\n//g' – Sundeep Mar 2 '18 at 3:43

You can actually do this with just JQ:

$ curl -L -O -u ian.guinto:W0lfg@ng131994 \

$ jq '.comments[].body | rtrimstr("\r\n") | gsub("\r\n"; " ")' comment
"Test comment"
"test comment 2"
"test comment3 Test comment 4"


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.