I need to extract RJ3fadfiasdUYBxF6z
from:
{"user":{"id":1325135,"uuid":"134513451","email":"[email protected]","joined_at":"2012-01-01T013:511:124.000Z","username":"testicl","title":"testli","thumb":"https://plex.tv/user/avatar?c=","hasPassword":true,"authToken":"RJ3fadfiasdUYBxF6z","authentication_token":"RJ3fadfiasdUYBxF6z","subscription":{"active":false,"status":"Inactive","plan":null,"features":["adaptive_bitrate","collections","photos-metadata-edition","radio","photos-favorites","federated-auth","Android - PiP","publishing_platform","news","kevin-bacon","client-radio-stations","TREBLE-show-features","web_server_dashboard","conan_redirect_qa","conan_redirect_alpha","conan_redirect_beta","transcoder_cache"]},"roles":{"roles":[]},"entitlements":[],"confirmedAt":"2012-01-01T13:31:31.000Z","forumId":23573,"rememberMe":false}}
regex with PCRP works great
(?<=authToken\":\")(\w+)
How can I extract RJ3fadfiasdUYBxF6z
using either awk
, sed
, or grep
without positive lookbehind? I don't have perl support.
I'm doing this out of a bash script on an openwrt router.
May be you could install jq
and use it?
jq .user.authToken < a.json
"RJ3fadfiasdUYBxF6z"
You can use the following sed
command:
sed 's/.*"authToken":"\([^"]*\)".*/\1/' file
It sounds like grep
is fair game
grep -Po '(?<=authToken\":\")(\w+)' file
Note: This needs an extra library, libpcre
, for grep
's native PCRE support.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With