This'll do it:
$ perl -nle 's/([0-9]?\d\d?|2[0-4]\d|25[0-5])\.([0-9]?\d\d?|2[0-4]\d|2 +5[0-5])\.([0-9]?\d\d?|2[0-4]\d|25[0-5])\.([0-9]?\d\d?|2[0-4]\d|25[0-5 +])/xxx.xxx.xxx.$4/; print' filename
Depending on what your file contains, this can be simplified a lot, though. If it's e.g. one IP address per line, the following will also be fine:
$ perl -nle 's/\d+\./xxx./g; print' filename
But in the presence of other data, it may or may not work as intended, and also note it neither cares about IP addresses having four fields, nor about each field ranging from 0 to 255, or in fact consisting of no more than three decimal digits.
When in doubt, I'd suggest using the first one, even if it's a bit unwieldy.
In reply to Re: Filtering out IP addresses
by AppleFritter
in thread Filtering out IP addresses
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |