Issue
This is for an assignment so I have no choice but to use sed.
Given a file messages, how can I extract all the IP addresses and print them?
sed -n '/((1?[0-9][0-9]?|2[0-4][0-9]|25[0-5])\.){3}(1?[0-9][0-9]?|2[0-4][0-9]|25[0-5])/p' messages
But it printed nothing. After doing some research, I found out that sed does not support non-greedy operators like ? and |.
I've been wracking my brain but I can't think of a way to do this without the non-greedy operators. How can I do this?
Solution
Use sed -r
(extended regex) or escape the capture groups with \
Answered By - Explosion Pills Answer Checked By - Marie Seifert (WPSolving Admin)