Best Approach Discovered
Best Approach Discovered
- $1 (positional parameter one) will assign the pattern match from the beginning of the line “.*”
- This includes all characters up until the opening square brace
- $2 (positional parameter two will be the first pattern match of five or more digits.
- Notice backslashes aren’t required for closure expressions (ie: use of parentheses for positional variables)
- Closure expression not available with awk/nawk
#!/usr/local/bin/perl
$[ = 1; # set array base to 1
while (<>) {
chop; # strip record separator
if (/^(cme|cbt|lif|smx)/) {
/^(.*)[[]([0-9]{5,})/ && printf "%-18s%8d\n", $1, $2;
}
}