Using awk with different input/output separators

Posted by

I had to reformat some stuff from the man pages for inclusion in another document that would be converted to a proper table. Here’s a trick for using awk/gawk to take the input (multiple spaces) and output with tabs using different input and output separators.

BEGIN { OFS = "t"; FS = "[ ][ ]+" }{ print $1,$2,$3,$4 }

I only wanted the four columns from the original table, hence why I specified them explicitly here.