0

I have this input

[{"email":"etu@etu"},{"email":"hg"},{"email":"ismail"}]

and I want to extract only the value on the email using bash.

Cyrus
  • 84,225
  • 14
  • 89
  • 153
Omar Amaoun
  • 526
  • 1
  • 3
  • 20

2 Answers2

2

Simply with jq:

echo '[{"email":"etu@etu"},{"email":"hg"},{"email":"ismail"}]' | jq -r '.[].email'

The output:

etu@etu
hg
ismail
RomanPerekhrest
  • 88,541
  • 4
  • 65
  • 105
-2

I recommend you use some unix tool for this and invoke it in your bash process.

Check this out: json command line processor

You probably want to investigate this one and you'll be probably good to go.

MarkSkayff
  • 1,334
  • 9
  • 14
  • A software recommendation alone is not a very good answer for Stack Overflow. Show how it applies to the OP's problem. – tripleee Mar 05 '18 at 03:23