1. A way to get a group of numbers would be to add an asterisk. Enter: ```bash-notab-nocopy grep -oP '[0-9]*' kern.log ``` > Notice the results are now numbers with multiple digits, but not IPv4 addresses. > For commands you need to repeat with only minor changes, you can press the **up arrow** on your keyboard to display the previous command. If you press the **up arrow** repeatedly, you can view any and all of the previous commands in the shell history. You can also use the **down arrow** to view more recent commands from history until you return to an empty prompt. You can also press **CTRL+C** to jump out of viewing a historical command back to an empty prompt. Once you are viewing the command you want to alter, then the **left arrow** and **right arrow** keys can be used to position your cursor where you want to add in other characters or remove them. 2. Add a dot to the number search. Enter: ```bash-notab-nocopy grep -oP '[0-9]*\.' kern.log ``` > In regex, a period (or dot) on its own is used to mean the pattern of 'any character'. Therefore, to indicate the exact character of a period, it needs to be escaped. > Notice the results are now numbers with multiple digits ending with a dot, but still not IPv4 addresses. 3. Limit the numbers to groups. 4. Switch to using the syntax that means 'any digit' (i.e., \d), use the pattern of at least one digit followed by more using the plus sign, and use this overall pattern four times. Enter: ```bash-notab-nocopy grep -oP '\d+\.\d+\.\d+\.\d+' kern.log ``` > The \d represents any digit. The + indicates one or more of the prior patterns. > Notice the results are now mostly IPv4 addresses. Technically, this could match something like 12124.13242.234.44. 5. Limit the digit groups to 1, 2, or 3 digits only with a pattern repeater match. Enter: ```bash-notab-nocopy grep -oP '\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}' kern.log ``` > The {1,3} indicates to match only 1, 2, or 3 instances of the pattern repeating. > Notice the results are now only IPv4 addresses. However, that is a lot to type out each time. 6. Simplify the regex by using a second-level pattern repeater. Enter: ```bash-notab-nocopy grep -oP '(\d{1,3}\.){3}\d{1,3}' kern.log ``` > Notice the results are now only IPv4 addresses. 7. Repeat the previous command, but capture the output into the file ipaddresses.txt by entering: ```bash-notab-nocopy grep -oP '(\d{1,3}\.){3}\d{1,3}' kern.log > ipaddresses.txt ``` Select the **Score** button to validate this task: 8. View the previous command's output in the less viewer by entering: ```bash-notab-nocopy grep -oP '(\d{1,3}\.){3}\d{1,3}' kern.log | less ``` Press the **spacebar** to look through the results. Press **q** to exit the less viewer.