#! /usr/bin/awk -f { string = NULL inside = 0 row++ columns = length($0) for(position = 1; position <= columns; position++) { char = substr($0, position, 1) if(char == "[") { inside = 1 column = position continue } if(inside) { if(char == "]") { number = ++strings[string] printf("X_%s_%d=%d ", string, number, column) printf("Y_%s_%d=%d ", string, number, row) printf("\n") string = NULL inside = column = 0 continue } if(char == " ") continue string = string char } } }