Yeah, perl and perl packages count as too heavy. I'm not against multiple steps. Super long command chains give me a thrill. I got reasonably close, but I was having particular trouble keeping my time formatting intact.
On Thu, Nov 16, 2017 at 2:01 AM, Tom <[email protected]> wrote: > sipcalc can do this - to do this right is not trivial as it requires > parser with lookahead or batracking. The shortening rules are designed > to be smart not simple for parsers. > > sipcalc $(echo "ipv6 Thu Nov 16 00:05:34 PST 2017 > [2603:01c2:1800:a8c0:0000:0000:0000:0001] foo bar baz" | sed > 's/.*\[\([^]][^]]*\)\].*/\1/')|awk '/Compressed address/ {print $4}' > 2603:1c2:1800:a8c0::1 > > if you want to filter the line you could wrap it in bash or insert the > sipcal call into the awk to keep/print the text around. > > If you could youse perl: > perl -e 'use Net::IP; my $ip = new Net::IP > ("2603:01c2:1800:a8c0:0000:0000:0000:0001",6); $ip = $ip->short(); > print ($ip."\n");' > 2603:1c2:1800:a8c0::1 > > Tomas > > On Thu, 2017-11-16 at 00:09 -0800, Russell Senior wrote: >> Can anyone suggest a nice unix pipeline filter using lightweight >> tools >> (no python) to output an ipv6 address in reduced format. That is, >> with >> the extra zeros removed and colons condensed according the normal >> ipv6 >> rules. Bonus for an example that leaves timestamps unscathed. In my >> case, the ipv6 address is inside square brackets. For example: >> >> ipv6 Thu Nov 16 00:05:34 PST 2017 >> [2603:01c2:1800:a8c0:0000:0000:0000:0001] foo bar baz >> >> should become: >> >> ipv6 Thu Nov 16 00:05:34 PST 2017 [2603:1c2:1800:a8c0::1] foo bar baz >> >> > _______________________________________________ > PLUG mailing list > [email protected] > http://lists.pdxlinux.org/mailman/listinfo/plug _______________________________________________ PLUG mailing list [email protected] http://lists.pdxlinux.org/mailman/listinfo/plug
