Why this difference between echo $Date
and echo "$(date +%s_%kh%M_le_%a_%d_%b_%Y)"
?
beginning=$(date +%s)
diff="0"
rest="$1"
tmp="0"
now="0"
Date=`date +%s_%kh%M_le_%a_%d_%b_%Y`
echo -n "$1"
while [ "$diff" -lt "$1" ]
do
let "now=$(date +%s)"
let "diff=now-beginning-1"
let "tmp=$1-diff"
if [ "$tmp" -lt "$rest" ]
then
echo
echo $Date
echo "$(date +%s_%kh%M_le_%a_%d_%b_%Y)"
let "rest=$1-diff"
echo -n ", $rest"
fi
done
echo ""
in output:
concatenatorus@gwenn-ha-du ~ $ countdown.sh 5
5
1425230747_18h25_le_dim._01_mars_2015
1425230749_18h25_le_dim._01_mars_2015
, 4
1425230747_18h25_le_dim._01_mars_2015
1425230750_18h25_le_dim._01_mars_2015
, 3
1425230747_18h25_le_dim._01_mars_2015
1425230751_18h25_le_dim._01_mars_2015
, 2
1425230747_18h25_le_dim._01_mars_2015
1425230752_18h25_le_dim._01_mars_2015
, 1
1425230747_18h25_le_dim._01_mars_2015
1425230753_18h25_le_dim._01_mars_2015
, 0
I use :
echo $BASH
/bin/bash
Date=...
andecho "$(date...
which operate more than 2 sec. What are you asking for?sh -x countdown.sh 5
.