Extract data between two points in a text file

前端 未结 2 719
轻奢々
轻奢々 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.

    0 讨论(0)
  • 2020-12-21 15:08
    cut -d= -f3 filename | grep -o '^[0-9]\+'
    
    0 讨论(0)
提交回复
热议问题