in this text file (class.txt) of the follong format Surname, Forename: Day.Month.Year: Degree
Sellen, Jo: 03.07.1986: MSc CSE
Parfitt, Harry: 20.03.1984: MSc ITHelp me to modify this shell script which uses AWK to read the file (class.txt)
awk '{gsub(/ +/,"\t");print}' class.txt
and output the data in the tabbed format as shown:
Surname Forename MSc stream Date of Birth
Sellen Jo MSc CSE 03.07.1986
Parfitt Harry MSc IT 20.03.1984* don't worry if tabbed columns don't line up.
cheerz
I am assuming that colums 4 and 5 are always the degree: #!/bin/ksh awk ' BEGIN { print "Surname Forename MSc stream Date of Birth" } { if(NR == 1) # skip the first line continue gsub(":","") # remove the colon gsub(",","") # remove the comma printf("%s %s %s %s %s\n", $1, $2, $4, $5, $3) } ' datafile.txt
Yes (14) | ![]() | |
No (14) | ![]() | |
I don't know (15) | ![]() |