#!/usr/bin/env awk
#
# Splits compound values and provides easy access to the subvalues.
# If num is omitted, val is split into distinct tab separated columns.
# If num > 0, returns the num repetition.
# If num < 0, returns the num item from the end, e.g., -1 => last element
#
# Dependencies:
#   - None
#
# See Also:
#   - splitr
#   - t2split
#
# Examples:
#   - tawk '{ print splitc($SrcMac_DstMac_NumP, 2) }' file.txt
#   - tawk 'splitc($SrcMac_DstMac_NumP, 2) == "00:11:22:33:44:55" { print splitc($SrcMac_DstMac_NumP) }' file.txt

@include "t2split"

function splitc(val, num) {
    return t2split(val, "_", num)
}
