When we search for content, sometimes we just need to show matching content.
At this time we can use the grep command.
➜ ~ grep 'line-number' test4.txt
You can also display the line number where the matching content is located.
linux grep -n
➜ grep -n 'line-number' test4.txt
Of course, you can also display the upper N lines, the lower N lines, or the upper and lower N lines of the line where the matching content is located.
linux grep -n -C
Show num lines before and after matching – grep -C
➜ grep -n -C 3 'line-number' test4.txt
Grep -C More info: grep show lines before and after