Reversing The Order of the IP Address with Sed

by bitznbitez

There exist absolutely no practical application for the following bit of sed.   Well no positive application anyway.   I suppose one could use it for the forces of evil.   Its point is to demonstrate matching of IP addresses in a file.

sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)/\4.\3.\2.\1/'

Its used as follows :

 %grep localhost /etc/hosts       loopback        localhost
%grep localhost /etc/hosts | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)/\4.\3.\2.\1/'       loopback        localhost