1

i want to rewrite first line but tput is removing all lines instead of first line

im testing this

cl=$(tput ed)
tput sc
echo 'line1____'
echo 'line2____'
echo 'line3____'
sleep 1
tput rc
echo "abc$cl"
echo ''
echo ''
sleep 1

when done it should look like

abc
line2____
line3____

but it is doing

abc
            -empty
            -empty
Thomas Dickey
  • 51,086
  • 7
  • 70
  • 105
stuffy
  • 48
  • 1
  • 5

1 Answers1

1

I think what you want is tput el (clear to end of line) instead of tput ed (clear to end of screen):

cl=$(tput el)

From the man pages for terminfo:

     Variable            Cap-      TCap       Description
      String             name      Code

clr_eol                  el        ce     clear to end of line (P)
                         ^^               ^^^^^^^^^^^^^^^^^^^^

clr_eos                  ed        cd     clear to end of screen (P*)
                         ^^               ^^^^^^^^^^^^^^^^^^^^^^

When I make this one change (cl=$(tput el)) to your code it now generates:

abc
line2____
line3____
markp-fuso
  • 28,790
  • 4
  • 16
  • 36