[CentOS] OT ? Shell script
Jonathan Wright
mailing-lists at djnauk.co.ukSun Dec 4 21:18:12 UTC 2005
- Previous message: [CentOS] OT ? Shell script
- Next message: [CentOS] OT ? Shell script
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
� wrote: > How about something like: > > YEAR=2005 > MONTH=12 > for ((DAY=1;DAY<=31;++DAY)); do > LC_ALL=C TZ=UTC date -d "$YEAR-$MONTH-$DAY" > done | grep "^Mon " | head -n 3 | tail -n 1 > > Possibly without the TZ=UTC depending on your needs... A better and faster option is to work out what day of the week the 21st falls on (e.g. Wednesday, or 4) and count back that value (minus 1 to count for Sunday): M=12 Y=2005 echo date +%d -d $Y/$M/$((21-$(($(date +%w -d $Y/$M/21)-1)))) -- Jonathan Wright ~ mail at djnauk.co.uk ~ www.djnauk.co.uk -- 2.6.14-gentoo-r2-djnauk-b1 AMD Athlon(tm) XP 2100+ up 10:41, 4 users, load average: 1.02, 1.06, 0.96 -- cat /dev/random (because u never know, u may see something u like) -- "Be who you are and say what you feel, because those who mind don't matter and those who matter don't mind." ~ Dr. Seuss
- Previous message: [CentOS] OT ? Shell script
- Next message: [CentOS] OT ? Shell script
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the CentOS mailing list