I am new to Linux. If I use grep and there are so many results that they cannot all be displayed at once, how can I view the results page by page, so that I get a chance to see them all without missing any?
Using grep -c alone will count the number of lines that contain the matching word instead of the number of total matches. The -o option is what tells grep to output each match in a unique line and then wc -l tells wc to count the number of lines. This is how the total number of matching words is deduced.
You can use grep with -A n option to print N lines after matching lines. Using -B n option you can print N lines before matching lines. Using -C n option you can print N lines before and after matching lines.
1 grep as a Filter. grep is very often used as a "filter" with other commands. It allows you to filter out useless information from the output of commands. To use grep as a filter, you must pipe the output of the command through grep .
try
grep YOUR_PATTERN_AND_OPTION YOUR_PATH | less
or
grep YOUR_PATTERN_AND_OPTION YOUR_PATH | more
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With