E
E
enabl32018-03-19 18:41:34
linux
enabl3, 2018-03-19 18:41:34

How to display a variable in real time?

Hello.
Is it possible in a bash script to display a variable that is updated every 2-3 seconds in the same place?
At the same time without stopping its further execution?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Z
Ziggy Pop, 2018-03-19
@ZiggyPop

To position the cursor and display the results of executing a certain command in a certain familiarity, you can use the value of the PS1 variable.
Here is documentation with examples:
https://wiki.archlinux.org/index.php/Bash/Prompt_c...
Here is one example from there, the time will be displayed in the top right corner:

PS1=">\[\033[s\]\[\033[1;\$((COLUMNS-5))f\]\$(date +%H:%M)\[\033[u\]"

V
Vladimir Kuts, 2018-03-19
@fox_12

watch -n <период обновления> <скрипт или команда которая выводит значение>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question