Use grep to report back only line numbers

前端 未结 8 1463
被撕碎了的回忆
被撕碎了的回忆 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:42

    You're going to want the second field after the colon, not the first.

    grep -n "text to find" file.txt | cut -f2 -d:

提交回复
热议问题