This is an attempt to clean out my scripts and to stop using temporary files to pass data.
I have two scripts: ScriptA (aka, "loudmouth"), and ScriptB (aka, "watcher"):
Code:
#!/bin/bash
#loudmouth.sh
i=1
while [ $i -lt 100 ];do
echo "Look at me count!$i"
sleep 1
let "i=$i+1"
done
Code:
#!/bin/bash
#watcher.sh
oneline(){
PROC=$1
while [ -d /proc/$PROC ];do
echo -en "\r" "`tail -n1 tmp.txt`"
done
}
( eval $1 ) &>tmp.txt & oneline $!
And you activate my current example with:
Code:
>watcher.sh loudmouth.sh
I would like to have these same results without using tmp.txt AND without changing loudmouth... in other words, I would like to stream data into a variable, and randomly read out the last line of that variable.
^_^ SO, to recap:
I currently write to a file continuously, and randomly read the last line of that file to see how the process is progressing.
I would like to write to a variable continuously, and randomly read the most recent line of that variable to see how the progress is progressing.
Thanks!