Archive

Archive for July 30, 2010

Split function in awk

Syntax:
======
     count = split(string,array,delimiter);
Example
======
     splittext=”This is a sentence”

     count_items = split(splittext,splitarray, ” “);

output:
=====

     splitarray[1]=”This”
     splitarray[2]=”is”
     splitarray[3]=”a”
     splitarray[4]=”sentence”

Loop thru the result:
===============

     for(i=1;i<count_items;i++)
     {
           print splitarray[i]
     }

Advertisements
Categories: awk, Technical