On Thu, 24 Sep 2009, eatsubway wrote: > > sry i have a stupid question. > > I have a variable and need to know how many items are in it. > > for example: > variable="abc xyz foo" > what program can i call to print out 3 > > right now im doing this... > > Counter() > { > echo $# > } > Counter $IDs > but that just seems stupid
That's a perfectly good way of doing it, but you will want to turn off filename expansion if there's a chance that the value may contain wildcards: set -f Counter $IDs set +f -- Chris F.A. Johnson, webmaster <http://woodbine-gerrard.com> =================================================================== Author: Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)