Bash Dynamic command line output

I was wondering how to get dynamic output in a shell. I mean the type of output that you get with the "top" command or the status bar to load wget: the command line output changes without any new line.

my specific needs are to get feedback from a script (which takes a lot to be done with a lot of operations) without getting a new line for every operation feedback, like opening a script that sends pings to a very large network and can dynamically report about the opening status.

(no, I can't use nmap: D anyway for research purposes)

thank!

+4
source share
2 answers

"" - . , . ncurses. script tput.

"" .

#!/bin/sh

# Restore cursor and move to new line when terminated
trap 'tput cnorm; echo' EXIT
trap 'exit 127' HUP INT TERM

# Make text cursor invisible
tput civis
# Save cursor position
tput sc
while true; do
  for char in '-' '\' '|' '/'; do
    # Back to saved position
    tput rc
    printf "%s" "$char"
    sleep 1
  done
done
+2

bash. http://tldp.org/HOWTO/Bash-Prompt-HOWTO/x361.html

, - :

echo -ne '\033[s'; clear ; for i in `seq 10`;do echo -ne '\033[0;0H' ; date;sleep 1;done ;echo -ne '\033[u'
+1

All Articles