In this example, we will print just the received data from the eth0 interface.
Using just the ifconfig eth0 command, a heap of data can be printed to the screen. To show just the packets received, we can isolate the lines that contain RX packets (RX for received). This is where grep comes in:
$ ifconfig eth0 | grep "RX packets"
Using the pipe or vertical bars, we can take the output of the ifconfig command and send it to the input of the grep command. In this case, grep is searching for a very simple string, RX packets. The search string is case sensitive, so we need to get this right or use the -i option with grep to run the search as case insensitive, as shown in the following example:
$ ifconfig eth0 | grep -i "rx packets"
We can see the result of the initial command in the following screenshot, confirming that we have been able to isolate just the single line of output, as shown: