![]() |
|
|
google unix.com
|
|||||||
| Fóruns | Registar | Fórum Regimento | Ligações | Álbuns | FAQ | Lista deputados | Calendário | Pesquisa | Today's Posts | Mark Forums Read |
| Programação Shell Script e Post perguntas sobre ksh, CSH, SH, BASH, Perl, PHP, SED, Awk e outros scripts shell e shell scripts línguas aqui. |
Mais UNIX e Linux Fórum Tópicos Você pode achar Helpfull
|
||||
| Fio | Thread Starter | Fórum | Respostas | Última postagem |
| contagem em unix? | JamieMurry | UNIX para Dummies Perguntas & Respostas | 5 | 04-23-2009 08:15 |
| Mostrar em uma contagem regressiva executar o script bash? | Starcast | Programação Shell Script e | 11 | 04-02-2009 07:20 |
| Shuttleworth começa contagem regressiva para Ubuntu 8/04 libertação | iBot | UNIX e Linux RSS Notícias | 0 | 04-17-2008 05:20 |
| Micro Countdown 1.0 (Default sucursal) | iBot | Software Release - RSS Notícias | 0 | 03-25-2008 09:30 |
| shell script - loop de contagem regressiva | froggwife | UNIX para Dummies Perguntas & Respostas | 2 | 11-29-2001 10:48 |
![]() |
|
|
Linkback | Thread Tools | Pesquisar este Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Código:
#!/bin/sh
XMAS=`date -d "Dec 25" +%j`
TODAY=`date +%j`
DAYS=$(($XMAS - $TODAY))
if [[ ! $DAYS =~ ^[0-9+$ ]]; then
echo There are $DAYS days left until Xmas.
else
echo Merry Xmas and Happy New year\!
fi
|
|
||||
|
Este script utiliza Julian Dias. Isto é, se tiver overkill GNU data (Linux)
Código:
#!/bin/ksh
jd=0
fraction=0
JD() # $1==day $2=month $3=year
{
day=$1
month=$2
year=$3
jd=0
if [[ $month -lt 3 ]] ; then
year=$(( $year - 1 ))
month=$(( $month + 12 ))
fi
a=$(( $year / 100 ))
b=$(( $a / 4 ))
c=$(( 2 - $a + $b ))
e=$(echo "365.25 * ( 4716 + $year ) " | bc -l)
f=$(echo "30.6001 * ( $month + 1)" | bc -l )
if [[ $year -gt 1581 ]] ; then
jd=$(( $c + $day + $e + $f ))
jd=$( echo "$jd - 1524.5" | bc -l )
fi
export jd
}
hr=$(( $(date "+%H") * 3600 ))
min=$(( $(date "+%M") *60 ))
sec=$(date "+%S")
fraction=$( echo "$hr/86400 + $min/86400 + $sec/86400"| bc -l)
JD $( date "+%d %m %Y" )
today=$( echo "$jd + $fraction" | bc -l)
yr=$( date "+%Y" )
JD 25 12 $yr
xmas=$jd
difference=$(( $xmas - $today ))
if [[ $difference -lt 0 ]] ; then
yr=$(( $yr + 1 ))
JD 25 12 $yr
xmas=$jd
difference=$(( $xmas - $today ))
fi
echo "Days to Christmas: $difference"
|
![]() |
| Marcadores |
| Thread Tools | Pesquisar este Thread |
| Display Modes | Esta taxa Thread |
|
|