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

Allen Baranov allen at isa.co.za
Tue Nov 12 13:06:18 UTC 2002


Hi,
Or just simply:

date +%y%m%d -d "yesterday"
021111

Allen Baranov

On Tue, 2002-11-12 at 14:50, Tethys wrote:
> 
> "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



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




More information about the GLLUG mailing list