bug-bash
[Top][All Lists]
Advanced

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

Re: Real easy questions. Please answer


From: Chris F.A. Johnson
Subject: Re: Real easy questions. Please answer
Date: Fri, 25 Sep 2009 04:22:08 -0400 (EDT)
User-agent: Alpine 2.00 (LMD 1167 2008-08-23)

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)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]