Nov
23

How to split a string using Awk

Using Awk a string may be split at least using two different methods.
Let’s split the strings given in file foo. The file consists of 5 columns separated by a comma (,) so we will split the lines at “,”.
Split
awk ‘{split($0,array,”,”)}{print array[1],array[2],array[3],array[4],array[5]} foo
-F
awk -F “,” ‘{print $1,$2,$3,$4,$5}’ foo
Where foo is a file such as this e.g:
1005.709115,-3.974680,0.081765,3.265020,Wed… Continue reading »