Skip to navigation
Use grep to search a file for all lines containing the string and then extract the IP addresses from those lines
02.04.26
use grep to search a file for all lines containing the string and then extract the IP addresses from those lines ``` grep "custom_options" foo-access.log| grep -oE '([0-9]{1,3}\.){3}[0-9]{1,3}' ```
https://en.wikipedia.org/wiki/Grep
Reply
Anonymous
pip it to sort -u to get only the unique ``` grep "custom_options" your_file.log | grep -oE '([0-9]{1,3}\.){3}[0-9]{1,3}' | sort -u ```
02.04.26
Reply
Anonymous
Information Epoch 1775865214
Effectiveness beats efficiency.
Home
Notebook
Contact us