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
  • 77,979
  • 13
  • 71
  • 125
Omar Amaoun
  • 476
  • 1
  • 3
  • 19

2 Answers2

2

Simply with jq:

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

The output:

etu@etu
hg
ismail
RomanPerekhrest
  • 75,918
  • 4
  • 51
  • 91
-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,224
  • 9
  • 12
  • 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