I have the below code which prints the elements of an array delimited by a ":" terminating in a new line.
The code is somewhat unwieldy - is it possible to find a more succinct way of doing this?
cat data.tmp |awk '
BEGIN { OFS=":" }
{ split($0,A,",") }
{
if (A[8] ~/trunk_priority=/) {
printf("%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n", A[1],OFS,A[2],OFS,A[4],OFS,A[5],OFS,A[6],OFS,A[7],OFS,A[8],OFS,A[9],OFS,A[10],OFS,A[11],OFS,A[12])
}
else {
printf("%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n", A[1],OFS,A[2],OFS,A[4],OFS,A[5],OFS,A[6],OFS,A[7],OFS,A[8],OFS,A[9],OFS,A[10],OFS,A[11])
}
} ' >output
thanks,
The code is somewhat unwieldy - is it possible to find a more succinct way of doing this?
cat data.tmp |awk '
BEGIN { OFS=":" }
{ split($0,A,",") }
{
if (A[8] ~/trunk_priority=/) {
printf("%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n", A[1],OFS,A[2],OFS,A[4],OFS,A[5],OFS,A[6],OFS,A[7],OFS,A[8],OFS,A[9],OFS,A[10],OFS,A[11],OFS,A[12])
}
else {
printf("%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n", A[1],OFS,A[2],OFS,A[4],OFS,A[5],OFS,A[6],OFS,A[7],OFS,A[8],OFS,A[9],OFS,A[10],OFS,A[11])
}
} ' >output
thanks,