0

The output I'm trying to accomplish is something along the lines of:

     line1 = get
     line2 = shwifty
     line3 = in
     line4 = here

...and in the command-line be refreshing all of those strings without continuously reposting new lines! I can get this working a few ways IF ONLY ONE LINE IS USED but how would I write over or backspace past MULTIPLE lines??

Right now, the command prompt will yield:

     line1 = get
     line2 = shwifty
     line3 = in
     line4 = here
     line1 = get2
     line2 = shwifty2
     line3 = in2
     line4 = here2

how can I just "refresh" the four lines that I want?

driedupsharpie
  • 133
  • 2
  • 10
  • You could use [NCurses](http://stackoverflow.com/questions/2907321/ncurses-and-perl-any-guides) or write [ANSI codes](https://en.wikipedia.org/wiki/ANSI_escape_code) if your terminal supports it (they likely do). – Kenney Nov 29 '15 at 00:00

1 Answers1

1

For multiple lines, the tput command is helpful. A demo:

clear
for ((i=1; i<=4; i++)); do 
    tput cup 0 0
    printf "%s$i\n" get shwifty in here
    sleep 1
done
glenn jackman
  • 238,783
  • 38
  • 220
  • 352