0

I'm getting this string data from curl command

{"password": [["passwordreal", "2035/01/01 00:00"]], "user": "user1", "address": "kobebkokoko.net"}

How do I get passwordreal using sed?

Example,

curl xxxx | sed -n '/ *"password"' => Been working on this long hours.

3

Using jq, you would get the raw password string with

curl ... | jq -r '.password[0][0]'

I.e., get the first element of the array-in-array of the password key in the returned JSON object.

Using sed in this instance would be a mistake, as the password string could possibly contain any character, including JSON encoded data that you would have to decode separately. jq does this for you.

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.