# Re: counter

**URL:** <https://www.ruby-forum.com/t/re-counter/74712>\
**Category:** Ruby\
**Created:** [November 7, 2006, 10:53am UTC](https://www.ruby-forum.com/t/re-counter/74712 "2006-11-07T10:53:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gennady\_B](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/c57346/32.png) [@Gennady\_B](https://www.ruby-forum.com/u/Gennady_B)\
**Post date:** [November 7, 2006, 10:53am UTC](https://www.ruby-forum.com/t/re-counter/74712/1 "2006-11-07T10:53:35Z")

</div>

removed\_email\_address@domain.invalid wrote:

> 6  
> 7  
> 8  
> 9  
> 10  
> etc…
> 
> but I don’t want a linebreak after the counter is displayed. I want it  
> just to keep refreshing itself, basically. Am I missing something  
> with puts or print or p? Any ideas?

$stdout.sync = true  
20.times do |\_counter|  
counter = \_counter.to\_s  
print counter + “\b” \* counter.size  
sleep 1  
end

FYI: puts and p both add “\n” to the output if it is not yet there.

Gennady.

---

<div class="post-metadata">

**Author:** ![Gennady\_B](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/c57346/32.png) [@Gennady\_B](https://www.ruby-forum.com/u/Gennady_B)\
**Post date:** [November 7, 2006, 10:53am UTC](https://www.ruby-forum.com/t/re-counter/74712/2 "2006-11-07T10:53:37Z")

</div>

Gennady B. wrote:

> removed\_email\_address@domain.invalid wrote:

(snip)

> end
> 
> FYI: puts and p both add “\n” to the output if it is not yet there.  
> printf doesn’t
