I have a JSON like below coming from curl command and it is present in a output.txt file. I want to retreive the JIRA status, here it is "In Progress"
{
"self": "https://jira.com/jira/rest/api/2/issue/1",
"fields": {
"status": {
"self": "https://jira.com/jira/rest/api/2/status/10170",
"description": "",
"name": "In Progress",
"id": "10170"
}
}
}
I have a restriction to use only sed . I tried like below it does not work . I am not sure how to navigate to the name value. can you please suggest to print JIRA status
sed -n 's|.*"fields":{"status":{"name":"\([^"]*\)".*|\1|p' output.txt
sed -nE '/"name":/ s/.*"(.+)".*/\1/p'orawk -F'"' '/"name":/{print $4}'assuming only one line will match when searching for"name":sed -n 's/^[[:space:]]*"name": "\(.*\)",/\1/p' file, see ideone.com/VuKvrY. Do you really need to check forfields":{"status"presence?