LoginSignup
4
1

More than 5 years have passed since last update.

シェルスクリプトでjsonの値を取得する

Posted at

下記のようなjsonの値をシェルスクリプトでぶっこ抜く備忘録。
jqコマンドが入っていない場合は別途インストール。


{"path":"/","code":"200","remote":"xxx.xxx.xxx.xxx","agent":"useragent"}
# agentをぶっこ抜く
agent=$(echo $json | jq '.agent' | cut -c 2- | rev | cut -c 2- | rev)
4
1
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
1