[Bash scripting] uptiime - print in loop with time interval

When I was installing Gentoo on Virtual Machine, I want to see what is my uptime. I have to run command "uptime", few second wait and run command "uptime" again. It was so annoying. I try to open uptime help and I saw only one option: -V to print version. I decided to write my own uptime command/function in bash which is using uptime and I educated myself by search how to implement my idea a little bit, because i have no experience in scripting in bash. And here is my bash code:
#!/bin/bash

function utime()
{
   while true; do
       uptime
       read -s -t 3 -n 1 key
       
       if [[ $key = q ]]
       then 
            break
       fi
   done
}

3 komentarze: