in reply to One Liner
G'day dirtdog,
"The objective is to return the unique values in the {108: tag."
The data you've identified as being the unique values (8480963411 and 8481963413) are not unique: both occur twice. Unfortunately, that raises questions about whether: your spec is incorrect; the wrong input data was presented; the expected output was wrong; and so on.
This gets the expected values you've identified into a shell variable using a one-liner with the input data you've shown.
$ echo $PM_1225496 $ PM_1225496=`perl -Mstrict -Mwarnings -ne 'BEGIN { $/ = "{S:{CON:}}" +} while (/^.*?\{108\:(\w+)\}\}.*$/g) { print "$1\n" }'` {1:6392495900}{4:{177:1807300738}{451:1}{405:K22005}{108:8480963411}}{ +1:6392495900}{2:IVSN}{3:{108:8480963411}}{5:{MAC:00000000}{CHK:9F11}} +{S:{CON:}}${1:6392495903}{4:{177:1807300738}{451:1}{405:K22005}{108:8 +481963413}}{1:6392495903}{2:IVSN}{3:{108:8481963413}}{5:{MAC:00000000 +}{CHK:12846}}{S:{CON:}} $ echo $PM_1225496 8480963411 8481963413 $
I'll leave you to decide if that's what you wanted.
— Ken
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: One Liner
by dirtdog (Monk) on Nov 09, 2018 at 19:25 UTC |