[comp.unix.programmer] Awk question

heal@mrcnext.uiuc.edu (Loren E. Heal) (03/03/91)

navarra@casbah.acns.nwu.edu (John Navarra) writes:


>My manual is not very helpful -- is there an awk function that specifies a 
>column number rather than a field number  such that I could get a " " as an
>answer if column # (say 16) is blank?

Use $0[15] to get the 16th character.  $0 means the whole line.
You might also use sprintf() or substr().  From my man page:

	...
     An input line is made up of fields separated by white space.
     (This default can be changed by using FS, vide infra.) The
     fields are denoted $1, $2, ... ; $0 refers to the entire
	 line.
	...
-->  substr(s, m, n) returns the n-character substring of s that
     begins at position m.  The function
     sprintf(fmt, expr, expr, ...) formats the expressions
     according to the printf(3S) format given by fmt and returns
     the resulting string.
--
Loren E. Heal : heal@mrcnext.cso.uiuc.edu, (UUCP)!uiucuxc!m.c.u.e!heal