Last active
September 9, 2016 09:50
-
-
Save songpp/7047eacf05f1c9989a6dfee1778e521d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| echo 1,2,4,5,6,9 a,b,d,e,f,i | gawk '{ | |
| split($1, Number, ","); | |
| split($2, Letter, ","); | |
| fourIdx = -1; | |
| nineIdx = -1; | |
| for(x = 1; x <= length(Number); x++) { | |
| if(Number[x] == 4) { | |
| fourIdx = x; | |
| } | |
| if(Number[x] == 9) { | |
| nineIdx = x; | |
| } | |
| } | |
| } | |
| END { | |
| if(nineIdx > fourIdx) { | |
| idx = fourIdx; | |
| sep = ""; | |
| nums = ""; | |
| letters = ""; | |
| while(idx <= nineIdx) { | |
| nums = nums sep Number[idx]; | |
| letters = letters sep Letter[idx]; | |
| idx ++; | |
| sep = "," | |
| } | |
| print nums " " letters; | |
| } | |
| }' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment