shell 脚本 如何解析这段字符串?

以下是网络返回的一段字符串,我想在 shell 脚本中解析这段字符串,获取 fsize 的值,也就是 13431719
请问该怎么做?

2018-06-14 14:38:26,380 - DEBUG - wcscmd version 1.0.0
2018-06-14 14:38:26,381 - DEBUG - Updating Config.Config ishttps->None
2018-06-14 14:38:26,381 - DEBUG - Updating Config.Config limit->None
2018-06-14 14:38:26,381 - DEBUG - Updating Config.Config marker->None
2018-06-14 14:38:26,381 - DEBUG - Updating Config.Config mode->None
2018-06-14 14:38:26,382 - DEBUG - Updating Config.Config output->None
2018-06-14 14:38:26,382 - DEBUG - Updating Config.Config overwrite->None
2018-06-14 14:38:26,382 - DEBUG - Updating Config.Config prefix->None
2018-06-14 14:38:26,382 - DEBUG - Updating Config.Config separate->None
2018-06-14 14:38:26,382 - DEBUG - Updating Config.Config upload_id->None
2018-06-14 14:38:26,382 - DEBUG - Command: stat
2018-06-14 14:38:26,383 - DEBUG - Start to get the stat of rsrj-test001:vikii/test02.mp4
2018-06-14 14:38:26,603 - DEBUG - (200, {'mimeType': 'video/mp4', 'code': 200, 'hash': 'ltVu-sfde4Uoq-86-gvx3Ase_j70', 'name': 'vikii/test02.mp4', 'fsize': 13431719, 'expirationDate': '', 'message': 'OK', 'putTime': 1528958272000L, 'result': True}, {'x-reqid': '202829121214713520180614143826YQP4KbiG'})
阅读 3.2k
3 个回答

egrep -o "'fsize': (\d*)" txt | cut -d ' ' -f 2

给你一种,自己思考下其他方法吧

grep -Po "200.+?'fsize': \K\d+"

grep -Po "'fsize': +\d+" test.log   | cut -d ' ' -f 2
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题