M
M
mars natsuhiboshi2015-02-19 20:23:22
linux
mars natsuhiboshi, 2015-02-19 20:23:22

[Solved] Shell echo not scrolling output?

There is a simple script made by a noob:

#!bin/sh
while true
 do
 a=`ipfw show | grep ng |wc -l`
 b=`date | cut -c12-19`
 sleep 1
 echo "$b Currently alive sessions: $a"
 done

And, accordingly, the question is:
When the script is running, it constantly produces a new line with the result, how to organize it so that it would not display a new line constantly, but update the existing one?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
DevMan, 2015-02-19
@mars_unique

askubuntu.com/a/16151

M
mars natsuhiboshi, 2015-02-19
@mars_unique

And yet, using the example of sh, and not bash, I decided like this:

#!bin/sh
while true
 do
 a=`ipfw show | grep ng |wc -l`
 b=`date | cut -c12-19`
 sleep 1
printf "$b Current ng interfaces count is:$a \r"
 done

Suddenly someone young will fly in search of a similar solution, I will advise you - man printf

K
kekoz, 2015-04-14
@kekoz

man is unsupportable? :)
echo -n "some shit..."

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question