On Which Line Number Was the Regex Match Found?

前端 未结 3 755
情深已故
情深已故 2021-01-25 08:55

I would like to search a .java file using Regular Expressions and I wonder if there is a way to detect one what lines in the file the matches are found.

Fo

3条回答
  •  甜味超标
    2021-01-25 09:28

    If you are using a Unix based OS / terminal, you could use sed:

    sed -n '/regex/=' file
    

    (from this StackOverflow response)

提交回复
热议问题