From 21f8a1e4fb1d2a5cfad782d93fa0bc9f22e4480c Mon Sep 17 00:00:00 2001 From: Nicolas Boisselier Date: Wed, 25 Jan 2017 11:46:59 +0000 Subject: [PATCH] html2txt --- etc/profile.d/net.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/etc/profile.d/net.sh b/etc/profile.d/net.sh index d4110be9..5df372d9 100644 --- a/etc/profile.d/net.sh +++ b/etc/profile.d/net.sh @@ -11,8 +11,7 @@ resolve() { ) | perl -MSocket -pe 'BEGIN{sub ip2host{$i=shift;return $c{$i} if $c{$i};$h=gethostbyaddr(inet_aton($i),AF_INET);%c=()if keys(%c)>10000;return $c{$i}=$h?$h:$i;};}; s/(\b)(\d+(?:\.\d+){3})(\b)/$1.ip2host($2).$3/ge' } -mask2cdr () -{ +mask2cdr() { # Assumes there's no "255." after a non-255 byte in the mask local x=${1##*255.} set -- 0^^^128^192^224^240^248^252^254^ $(( (${#1} - ${#x})*2 )) ${x%%.*} @@ -21,10 +20,13 @@ mask2cdr () } -cdr2mask () -{ +cdr2mask() { # Number of args to shift, 255..255, first non-255 byte, zeroes set -- $(( 5 - ($1 / 8) )) 255 255 255 255 $(( (255 << (8 - ($1 % 8))) & 255 )) 0 0 0 [ $1 -gt 1 ] && shift $1 || shift echo ${1-0}.${2-0}.${3-0}.${4-0} } + +html2txt() { + lynx -pseudo_inlines -nomargins -display_charset=utf8 -nocolor -nolist -width=999 -dump $@ +} -- 2.47.3