#!/bin/bash # BEGIN: Variables SUBNET_BEGIN_REGEX='^[[:space:]]*subnet[[:space:]]+[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+[[:space:]]+netmask[[:space:]]+[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+[[:space:]]+\{' # END: Variables get_subnet_declerations () { 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 -i OPEN_BRACKETS=0 local -i CLOSE_BRACKETS=0 local CAN_READ=0 while read line; do if [[ "$line" =~ ^$SUBNET_BEGIN_REGEX.*$ ]]; then CAN_READ=1 fi done <<< "$CONTENT" }