How would I overwrite the previously printed line in a Unix shell with Ruby?
Say I\'d like to output the current time on a shell every second, but instead of stackin
You can use the \r escape sequence at the end of the line (the next line will overwrite this line). Following your example:
\r
require 'time' loop do time = Time.now.to_s + "\r" print time $stdout.flush sleep 1 end