Re: script question

From: Hunter, Mark (Mark.Hunter@ANHEUSER-BUSCH.COM)
Date: Tue Jul 29 2003 - 14:49:55 EDT


NF is fields, NR is number of records

-----Original Message-----
From: Stephen Spalding [mailto:ssaixadm@YAHOO.COM]
Sent: Tuesday, July 29, 2003 1:42 PM
To: aix-l@Princeton.EDU
Subject: script question

Is there a way to display the number of fields in a
string using the awk command? Suppose I have a string
like this:

string="hi there, steve, how are you"

I want to be able to count the number of fields in
this string as delimited by the ','. It looks like I
want to do something like this:

echo $string | awk -F, '{print $NR}'

This should return 3, but it just returns 1. Can
anyone help me out here?

Thanks!

-Stephen Spalding

__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com



This archive was generated by hypermail 2.1.7 : Wed Apr 09 2008 - 22:17:04 EDT