18 lines
570 B
Bash
Executable File
18 lines
570 B
Bash
Executable File
#!/bin/bash
|
|
get_subnet_declerations () {
|
|
local SECTION_CONTENT SECTION_NAME
|
|
local -n HASH_TABLE="${1:?"get_subnet_declerations: Hash table was not provided"}"
|
|
local CONTENT="${2:?"get_subnet_declerations: Content to be parsed was not provided"}"
|
|
local -a SECTIONS
|
|
|
|
get_sections $SUBNET_BEGIN_REGEX SECTIONS "$CONTENT"
|
|
|
|
local IP_REGEX='[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+'
|
|
|
|
for i in ${!SECTIONS[@]}; do
|
|
SECTION_CONTENT="${SECTIONS[$i]}"
|
|
SECTION_NAME=`grep -Eo $IP_REGEX <<< "$SECTION_CONTENT" | head -n 1`
|
|
HASH_TABLE["$SECTION_NAME"]="${SECTION_CONTENT}"
|
|
done
|
|
}
|