title: how can I print with 3 digits in the c shell?
body: <p>I'd like to print with 3 digits such as 001, 002, ... not 1, 2, ... in the c shell.</p>
  <p>but  when I use the below example, I've got just number without 3 digits.</p>
  <p>So I want to know how to print the 3 digits number as 001 not 1.</p>
  <p>how can I print it with 3 digits in the c shell?</p>
  <pre><code>#!/bin/csh -f
  
   set j = 1
   while ( $j &lt;= 400 )
     echo &quot;Welcome $j times&quot;
     @ j++
   end
  </code></pre>
  <p>results</p>
  <p>0</p>
  <p>1</p>
  <p>...</p>
  <p>100</p>
  <p>...</p>
  <p>400</p>
  <h1>update</h1>
  <p>One more question. if I want to assign it as a variance from &quot; printf 'Welcome %03d times' $j&quot; itself.
  Like this,</p>
  <pre><code> set j = 1
   set k
  
   while ( $j &lt;= 400 )
     printf 'Welcome %03d times' $j
     k = printf 'Welcome %03d times' $j
  
     @ j++
   end
  </code></pre>
  <p>If I want to assign 3digit number into the k variance like this k=003 not k=3.
  what am I do ?</p>
  <h1>update2</h1>
  <p>when I ran the below code, I've got always 000 not increase.</p>
  <pre><code> set j = 1 
   while ( $j &lt;= 500 ) 
     echo &quot;Welcome $j times&quot; 
   set k = `perl -e 'print (sprintf (&quot;%03d&quot;, $j))'` 
     echo &quot;set k= $k &quot; 
  </code></pre>