in reply to Filtering out IP addresses
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Filtering out IP addresses
by kennethk (Abbot) on Jul 22, 2014 at 22:01 UTC | |
by AppleFritter (Vicar) on Jul 22, 2014 at 22:06 UTC | |
|
Re^2: Filtering out IP addresses
by Anonymous Monk on Jul 23, 2014 at 15:18 UTC | |
by AppleFritter (Vicar) on Jul 23, 2014 at 16:30 UTC |