I've been learning SED and GREP for couple of weeks now. Usually I use ATOM editor for building the regex and it has helped me alot. Now it doesn't take me more than few minutes to buid one.
But things start getting ugly when I try to use same regex against a data file using ubuntu terminal.
Could someone plz provide precise switches with grep and sed, also with limitations (like- GNU SED cannot use \d for digit, rather uses [0-9]).
Lets take below text and requirements for example:
192.168.10.10,fe80:0:0:0:bcf6:c04e:cb99:6909,10.0.170.11
172.16.32.44
fe80:0:0:0:84a5:1d2e:55d1:ecf,192.168.4.50
fe80:0:0:0:84a5:1d2e:55d1:ec1
10.10.101.22
After wrecking my head for hours I could figure out grep -P '(\d{1,3}\.){3}\d{1,3}'
to print the only IPV4 addresses. But this is PERL regex switch. So now I am hell confused about what to use and what not.
Plz help me build full SED and GREP commands for below requirements (assuming input is a file):
1- Print only IPV4 addresses using GREP.
2- Print everything except IPV4 addresses using GREP.
3- Print only IPV4 addresses using SED.
4- Print everything except IPV4 addresses using SED.
5- Replace IPV4 addresses with --- using SED.
6- Replace everything except IPV4 addresses using SED.