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