From: Rob Biedenharn Date: 2008-08-20T08:24:26+09:00 Subject: Re: overprinting characters 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 Rob Biedenharn http://agileconsultingllc.com Rob@AgileConsultingLLC.com