File: extract_networks6.sh

package info (click to toggle)
thc-ipv6 3.6-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 2,116 kB
  • sloc: ansic: 52,618; sh: 529; makefile: 77; perl: 34
file content (23 lines) | stat: -rwxr-xr-x 840 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/bin/bash
test -z "$1" -o "$1" = "-h" && {
  echo $0 FILE
  echo prints the networks found in FILE
#, specify - for stdin
  exit 1
}
test -e "$1" -o "$1" = "-" || {
  echo Error: File $1 not found
  exit 1
}

{
  test "$1" = "-" && {
    echo no
  } || {
    cat $1 | egrep :: | egrep -v '^[0-9a-fA-F]{1,4}:[0-9a-fA-F]{1,4}:[0-9a-fA-F]{1,4}:[0-9a-fA-F]{1,4}:[0-9a-fA-F]{1,4}|[0-9a-fA-F]{1,4}:[0-9a-fA-F]{1,4}:[0-9a-fA-F]{1,4}:[0-9a-fA-F]{1,4}:[0-9a-fA-F]{1,4}$' | sed 's/::.*/::/'
    cat $1 | egrep -v :: | awk -F: '{print $1":"$2":"$3":"$4"::"}'
    cat $1 | egrep :: | egrep '^[0-9a-fA-F]{1,4}:[0-9a-fA-F]{1,4}:[0-9a-fA-F]{1,4}:[0-9a-fA-F]{1,4}:[0-9a-fA-F]{1,4}|[0-9a-fA-F]{1,4}:[0-9a-fA-F]{1,4}:[0-9a-fA-F]{1,4}:[0-9a-fA-F]{1,4}:[0-9a-fA-F]{1,4}$' | sed 's/::/:0:0:/' | awk -F: '{print $1":"$2":"$3":"$4"::"}'
  }
} | sort -n

exit 0