From: Matt Harrison Date: 2008-08-20T08:45:34+09:00 Subject: Re: overprinting characters Rob Biedenharn wrote: > > On Aug 19, 2008, at 6:20 PM, Matt Harrison wrote: > >> I have a script that does things to large files > 1Gb and I want to be >> able to show the percentage through the current file. >> >> I know exactly how I will get the percentage, but I want to know how to >> display it in the terminal. >> >> What I would like is the name of the current file, then on the next >> line, "currentbytes/totalbytes [xx%]" and I want it to update the >> characters in place without writing hundreds of lines to the terminal. >> >> I think I want to be able to position the cursor back to the beginning >> of the current line but I have no idea how to do this in ruby. >> >> Grateful for any ideas >> >> Thanks >> >> Matt > > In addition to print "\r" you might want to look at the docs for > ProgressBar > > http://raa.ruby-lang.org/project/progressbar/ > > I can't remember where I used this or I'd drop an example in here, but > it gives to a bar similar to what sftp or curl shows on downloads (it > even gives a time to complete estimate). > > -Rob Excellent, first I managed to get it working as I said in my post, thanks to Axel's link. Now I am trying the progress bar as Rob suggested. It's good but I can't work out how the format is used. I'm trying to expand the amount of text displayed in the title so I can see the entire file and path. Any extra help is appreciated but thanks for what you've done so far ;) Matt