-1

How do I print using grep awk just to print success from the below string.

{"identity":"2320147","authentication":"success"}

tata
  • 33
  • 3
  • It looks like it's easier to parse using python or other tools than shell commands. see https://stackoverflow.com/a/1955555/5666087 – jkr Jan 23 '20 at 03:51

2 Answers2

0

Using GNU awk:

echo "{"identity":"2320147","authentication":"success"}" |awk -F "[:}]" '{print $3}'

Output:

success

User123
  • 1,498
  • 2
  • 12
  • 26
0

Use jq

test='{"identity":"2320147","authentication":"success"}'

$ jq -r '.authentication' <<< $test
success

JQ's help

$ jq -h
jq - commandline JSON processor [version 1.5-1-a5b5cbe]
...
     -r     output raw strings, not JSON texts;
...
Ivan
  • 6,188
  • 1
  • 16
  • 23