How to write a shell script which uses awk to read in the data file students.txt and output the data in the tabbed format as shown:
Surname Forename MSc Stream Date of Birth
Smith John IT 15.01.1986
Taylor Susan IT 04.05.1987
Thomas Steve MIT 19.04.1986
Do not worry if tabbed columns don’t line up.
The distance between each of (Surname, Forename, MSc Stream and Date of Birth) column is one tab.
Question:
Why this code bellow doesn't work for me?
awk 'BEGIN {IFS=" "} {OFS="\t"} {print $1,$2,$3,$4}' students.txt
IFSin awk man page, did you meanFS? If so, it's already set to separate fields on whitespace, not just single space. – gelraen Apr 4 '11 at 20:23?icon to see the available markup options. – Gilles Apr 4 '11 at 20:25awkthat?... I've barely touched on awk, so I'm guessing that would be a custom process for the first line in the main section... (but I've go no idea how) – Peter.O Apr 5 '11 at 9:18