shell - Date from date string in SunOS -


how can day name friday thursday date string in sunos 5.10 shell script. user input date in format yyyymmdd (20130816) have day name?

to number of day in week:

update - more complete script:

#!/bin/ksh  date="$1" daymap="0,sunday\n1,monday\n2,tuesday\n3,wednesday\n4,thursday\n5,friday\n6,saturday" eval $(echo "${date}" | nawk -f- '{printf("year=%s month=%s day=%s\n", $1, $2, $3)}')   day=`cal "${month}" "${year}" | nawk -v day="${day}" '   fnr > 2 {     for(i=1; <= nf; i++)       if ( $i == day) {         #printf("day->[%d] row->[%d]\n", $i, fnr-2)         printf("%d\n", (nf == 7 || fnr!=3) ? i-1 : i+(6-nf))         exit       }   } '`  echo $daymap | grep $day | cut -f2 -d',' 

then use map print full name of day. sunday 0.

input in format: 2013-08-16


Comments

Popular posts from this blog

assembly - 8086 TASM: Illegal Indexing Mode -

Java, LWJGL, OpenGL 1.1, decoding BufferedImage to Bytebuffer and binding to OpenGL across classes -

javascript - addthis share facebook and google+ url -