Skip to content

Instantly share code, notes, and snippets.

@apex-omontgomery
Created May 18, 2018 00:49
Show Gist options
  • Save apex-omontgomery/04a1443f0f4d7885870171383316b1f7 to your computer and use it in GitHub Desktop.
Save apex-omontgomery/04a1443f0f4d7885870171383316b1f7 to your computer and use it in GitHub Desktop.
split klv of length k
#!/bin/awk -f
# prints each klv based on beginning length on a new line
# 012TESTYYYNN014NEWSYYYNNYY
# 012TESTYYYNN
# 014NEWSYYYNNYY
{
for(columIndex=0; columIndex <=length($0); columIndex++)
{
currLen = int(substr($1, columIndex, 3) )
print substr($1,columIndex,currLen)
columIndex +=currLen
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment