Bash shell script update and print a variable overwriting the same line
<p>I been trying to print a variable in the same time for a scrip that pretends automatize a process the content is the output of this </p>

<pre><code>sed "s/Read/\n/g" /tmp/Air/test.txt | tail -1 test.txt | grep ARP
</code></pre>

<p>so i put this in a while loop </p>

<pre><code>    do
       out= sed "s/Read/\n/g" /tmp/Air/test.txt | tail -1 test.txt | grep ARP
       echo  -n  "$out"
       sleep 1
    done
</code></pre>

<p>i read other questions here and i try with different option like <code>echo -ne</code>, <code>echo -ne "$out" \r</code>, <code>printf "\r"</code> or <code>printf "%s"</code> and no luck with no one, all the other example don't have a variable to print just counter o system variables </p>

<p>Update </p>

<p>it seems to appear that the <code>echo -n</code> repeat <code>$out</code> in the same line, if <code>out="this is a test"</code> the output of <code>echo -n</code> is "this is a test this is a test this is a test this is a test ...." maybe im missing some option ?</p>

<p>Update 2 </p>

<p>sorry for the miss understood perhaps i was not very clear but what i want is overwrite the same line with the value of $out, the source of $out is the output of the aireplay-ng command that executes along with the script and i get the output with </p>

<p>the ouput is something like this</p>

<pre><code>102415 packets (got 5 ARP requests and 15438 ACKs), sent 37085 packets...(499 pps)
</code></pre>

<p>but the number of ARP request is changing constantly </p>

<p>this code for example use echo -ne and overwrite in the same line</p>

<pre><code>    #!/bin/bash
    for pc in $(seq 1 100); do
       echo -ne "$pc%\033[0K\r"
       sleep 1
    done
</code></pre>

<p>the output of this is like a percent indicator that shows "10%" and going instead of "1% 2% 3% 4% 5% .." in the same line and i already try like this but with no luck</p>