Reputation: 131
I want any stdout to display on one line only. Each successive line should overwrite the last.
Typically, I would do
echo -ne "Overwrite me. \033[0K\r"
But now I want to pipe the output, and since echo is not a filter I need to use sed or something e.g.
cat story.txt | some.sed.like.util.for.replacing.$.with.\033[0K\r
Upvotes: 0
Views: 99
Reputation: 158210
sed
can't be used since sed
will always append a newline to it's output. You need to use a while
loop in the shell:
while read -r line ; do
echo -en "\r\033[0K${line}"
sleep 1
done < story.txt
Upvotes: 1