help-bash
[Top][All Lists]
Advanced

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

Re: [Help-bash] Is it possible to directly use $# in for((;;))?


From: Matthew Cengia
Subject: Re: [Help-bash] Is it possible to directly use $# in for((;;))?
Date: Thu, 2 Apr 2015 12:39:49 +1100
User-agent: Mutt/1.5.21 (2010-09-15)

On 2015-04-01 20:33, Peng Yu wrote:
> Hi,
> 
> Of course, the following bash does not work. Is there a way to
> directly use $# instead of first assigning it to a variable? Thanks.
> 
> for((i=0;i<#;++i))
> do
>   echo $i
> done

Use $# instead of #.

address@hidden:tmp$ set -- a b c;
address@hidden:tmp$ for ((i=0;i<$#;++i)); do echo "$i"; done
0
1
2

-- 
Regards,
Matthew Cengia

Attachment: signature.asc
Description: Digital signature


reply via email to

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