I always need to find some key words in thousands of feedback and locate it in which line. I used to redirect feedback to a file, and open file wiith vim, and execute vim command :set nu
to do this. But it is pretty inconvenient and cause some unnecessary disk IO.
So I wonder if there is a command can achive below results:
$ sudo my-command | line-number-command | grep 'foo\|bar'
114 bla bla bla foo
514 bla bar bla bla
810 foo bla bla bla
1919 bla bla bar bla
nl
- butgrep
itself has a-n
option for line numbering – steeldriver Dec 24 '20 at 02:20