|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
how to deal with variable fields in AWK?
AWK scripting Question:
I have a string with a variable number of fields. ex: this is; the string; to look at The above example shows a string seperated with semicolons. The problem is that the output between the semi's is never exactly the same in that, the fields between the semi's are of a variable length. Also, there could be more or less semi's in the string. The only static part of the string is that there are no semi's at the beginning or end of the string. So I would like to know how, in an AWK script, I can deal with a variable number of fields seperated by the semi's? Help... Appreciate any help, Bob |
|
#2
|
|||
|
|||
|
You can set the field separators in the BEGIN action, e.g...
Code:
BEGIN {
FS=OFS=";"
}
Then you will always have $1 $2 and $3 - the fields you want |
![]() |
| Viewing: Dev Shed Forums > Operating Systems > UNIX Help > how to deal with variable fields in AWK? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|