Regarding 'for' loop in KornShell

后端 未结 4 1245
南旧
南旧 2020-12-20 03:56

Is there a way to implement the following using \'for\' in KornShell (ksh)? Here is the C equivalent:

for(i=1;i<20;i++)
{
    printf(\"%d\",i);
}
<         


        
4条回答
  •  渐次进展
    2020-12-20 04:12

    Unfortunately, it looks as if ksh does not have support for range-based brace expansion or support the (( )) construct so to do this compactly, you'll need to call the external binary seq like so:

    for i in $(seq 1 20); do
      echo $i
    done
    

提交回复
热议问题