Extract data between two points in a text file

前端 未结 2 745
轻奢々
轻奢々 2020-12-21 14:44

How would it be possible to extract data between two points in a text file?

E.g.

Reply: [200/OK] bytes=29086 time=583ms

The value b

2条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-21 14:59

    sed -n 's/.*time=\(.*\)ms/\1/p' < logfile
    

    This sets up a regular expression that captures everything between the time= and ms into the first capture group (which is referred to on the right-hand-side as \1) and prints it.

提交回复
热议问题