17 Mar
2022
17 Mar
'22
17:57
On 2022-03-17 18:11, Patrick Shanahan wrote:
this all but solves my need. I would also like to be able to drop the 4th quad and/or the 3rd and 4th.
I use this: $ cat ~/script/grepipnumber #!/bin/sh grep -E -o "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)"
Is that also possible?
Absolutely $ echo 1.1.1.1 | grepipnumber | awk -F. '{print $1"."$2}' 1.1 Often I need to append the net-part. Like so. $ echo 1.1.1.1 | grepipnumber | awk -F. '{print $1"."$2"."$3".0/24"}' 1.1.1.0/24 -- /bengan