Use grep to report back only line numbers

前端 未结 8 1459
被撕碎了的回忆
被撕碎了的回忆 2020-12-04 13:40

I have a file that possibly contains bad formatting (in this case, the occurrence of the pattern \\\\backslash). I would like to use grep to return

8条回答
  •  借酒劲吻你
    2020-12-04 14:35

    If you're open to using AWK:

    awk '/textstring/ {print FNR}' textfile
    

    In this case, FNR is the line number. AWK is a great tool when you're looking at grep|cut, or any time you're looking to take grep output and manipulate it.

提交回复
热议问题