![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Necesito la fecha de creacion, modificacion y ultimo acceso de un fichero! | palitodlselva | Shell Programming and Scripting | 1 | 10-09-2009 02:08 AM |
| Dada Mail 3.0.2 (Default branch) | iBot | Software Releases - RSS News | 0 | 12-30-2008 10:10 PM |
| Dada Mail 3.0.1 (Default branch) | iBot | Software Releases - RSS News | 0 | 11-26-2008 03:10 PM |
| Dada Mail 3.0.1 (Development branch) | iBot | Software Releases - RSS News | 0 | 11-11-2008 12:10 PM |
| Installing Dada engine | cptj | UNIX for Dummies Questions & Answers | 2 | 08-31-2005 06:50 PM |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
No logro solucionar sacar el dia de la semana de una fecha dada.
Con este código pretendo sacar el dia de la semana dada una fecha como parametro
por ejemplo. ./dia 27 10 2009 El resultado saliera: Martes El problema es que cuando llego casi al final el lunes etsa representado por un 0. el martes por 1.. y quiero hacer un bucle if para sustituir el 0 por Lunes de este modo if [$dow -eq 0] then echo -"Lunes" else fi Pero todo el rato me da error y no se porque. ¿Alguien me podria ayudar? Gracias #!/bin/sh # ja fe ma ap ma ju ju ag se oc no de set -A lasts 0 31 28 31 30 31 30 31 31 30 31 30 31 dia=$1 mes=$2 anyo=$3 # # Get Day of Week of Jan 1 dow1=$(cal 1 $anyo | sed -n '3s/. //gp') ((dow1=7-dow1)) # # Es año Bisiesto? leap=0 if ((!(anyo%100))); then ((!(anyo%400))) && leap=1 else ((!(anyo%4))) && leap=1 fi # # Establecer numero de dias de Febrero lasts[2]=28 ((leap)) && lasts[2]=29 # # calculate day of year i=0 previous=0 while ((i < mes)) ; do ((previous=previous+lasts[i])) ((i=i+1)) done ((doy=previous+dia)) # # Calculate day of week ((dow = (doy+dow1-1)%7 )) #echo dow = $dow echo diadelasemana=$dow if [$dow -eq 0] then echo -"Lunes" else echo "..ya seguiria con cada numero" fi exit 0 ---------- Post updated at 08:17 AM ---------- Previous update was at 08:10 AM ---------- Sorry i didn't realize that I had to write in English My problem is that i want to calculate the day of the week, i want to change result given as a number for the day. I mean, the program now do that if the day is Monday is represented by 0, Tuesday by 1.. but i want the word "Monday" as a result. I thought in a bucle if but there is always a mistake and i dont know why. Thank you |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|