[Gllug] RE: [GLUG] Year, month,day?

Tethys tet at accucard.com
Tue Nov 12 12:50:21 UTC 2002


"Matthew Leach" writes:

>Erm ... Im not exactly sure what you're asking, but I *think*
>you want to get the date in that form?
>
>You can use 'date'
>
>	date +%Y%m%d

I ran into a relatied issue recently. My problem was that if log files
roll over at midnight, then by the time I want to manipulate them, I want
to get yesterday's date, not today's. I ended up resorting to using:

	yesterday=$(echo $(date +%s) 86400 - p | dc | \
		awk '{ printf("%s\n", strftime("%y%m%d", $1)); }')

Crude, but it works.

Tet

-- 
Gllug mailing list  -  Gllug at linux.co.uk
http://list.ftech.net/mailman/listinfo/gllug




More information about the GLLUG mailing list