Currently I am converting all my Linux scripts to FreeBSD, which is reeeeaaaaally time consuming. Maybe a stupid question, but is there a script which can do it automatically?
But my current problem is to convert the date command.
I had a useful counter function in my .zsh_aliases, which could convert seconds in a time format, so if I put in 65 seconds as an argument the timer showed 00:01:05.
Here is the Linux version:
After reading that the --date flag isn't available and one should use the -v flag, I tried the following:
But it shows me a weird hour and minute and if the seconds are larger than 59 seconds, it doesn't work anymore.
If this is fixable I would be very thankful, but I am open to completely other ways of having a countdown in the terminal (showing HH:MM:SS).
Thanks a lot for your help.
But my current problem is to convert the date command.
I had a useful counter function in my .zsh_aliases, which could convert seconds in a time format, so if I put in 65 seconds as an argument the timer showed 00:01:05.
Here is the Linux version:
Code:
function countdown()
{
date1=$((`date +%s` + $1));
while [ "$date1" -ge `date +%s` ]; do
echo -ne "$(date -u --date @$(($date1 - `date +%s`)) +%H:%M:%S)\r";
sleep 0.1
done
}
After reading that the --date flag isn't available and one should use the -v flag, I tried the following:
Code:
function countdown()
{
date1=$((`date +%s`+$1));
while [ "$date1" -ge `date +%s` ]; do
echo -ne "$(date -v$(($date1 - `date +%s`))S +%H:%M:%S)\r";
sleep 0.1
done
}
But it shows me a weird hour and minute and if the seconds are larger than 59 seconds, it doesn't work anymore.
If this is fixable I would be very thankful, but I am open to completely other ways of having a countdown in the terminal (showing HH:MM:SS).
Thanks a lot for your help.