Want to make this while loop look cleaner

odragon

Dabbler
Joined
Nov 9, 2016
Messages
28
Hello all! I am currently upgrading my drives (yay) and I was trying to write a simple while loop to just output the status of the resilvering. What I have is:

while true; do zpool status | grep 'resilvered,'; sleep 30; done
101G resilvered, 8.45% done, 0 days 04:17:52 to go
103G resilvered, 8.64% done, 0 days 04:17:05 to go
105G resilvered, 8.83% done, 0 days 04:16:17 to go
108G resilvered, 9.04% done, 0 days 04:14:45 to go
110G resilvered, 9.23% done, 0 days 04:13:48 to go
112G resilvered, 9.37% done, 0 days 04:14:38 to go


As you can see it just keeps updating (which I wanted) but I only want to see the latest update like this:

while true; do zpool status | grep 'resilvered,'; sleep 30; done
112G resilvered, 9.37% done, 0 days 04:14:38 to go

Then after 30 seconds it just updates to the next output and doesn't insert another line underneath. I'm sure it's something stupid simple but I just can't seem to figure it out. Any help would be appreciated :)
 

droeders

Contributor
Joined
Mar 21, 2016
Messages
179
Try this - I think it does what you want:

while true; do echo -e '\f'; zpool status | grep 'resilvered,'; sleep 30; done
 
Top