[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [ProgSoc] Field variables from awk splitting...



On Thu, 28 May 1998, Eliseo Christopher d'Annunzio, Esquire wrote:

> What would be the field variable for the last field from a splitting? eg.
> $1 is the first field, $2 is the second... the last field is...?

$NF is set to the number of fields in each line, so

stuff | awk '{print $NF}' will print the last field on each line,

stuff | awk '{print $(NF-1)}' will print the second to last field, etc.

+---------------------------+-----------------------------------------+
|      Justin Warren        | justin.warren@nospam.its.maynick.com.au        |
|   Systems Administrator   | daedalus@nospam.progsoc.uts.edu.au             |
| Mayne Nickless Express IT | http://www.progsoc.uts.edu.au/~daedalus |
+---------------------------+-----------------------------------------+
| Just because you're paranoid doesn't mean they're NOT after you...  |
+---------------------------------------------------------------------+

--
You are subscribed to the progsoc mailing list. To unsubscribe, send a
message containing "unsubscribe" to progsoc-request@nospam.progsoc.uts.edu.au.
If you are having trouble, ask owner-progsoc@nospam.progsoc.uts.edu.au for help.

This list is archived at <http://www.progsoc.uts.edu.au/lists/progsoc/>