Posts from "October, 2009"

date function for bash commands

How to get date on bash/sh command?
[ad]

#!/bin/bash
# Datestamp e.g 2002-09-21_24h00m
DATE=`date +%Y-%m-%d_%Hh%Mm`

# Day of the week e.g. Monday
DATE=`date +%A`

# Day number of the week 1 to 7 where 1 represents Monday
DATE=`date +%u`

# Date of the Month e.g. 27
DATE=`date +%d`

# Month e.g January
DATE=`date +%B`

# Week Number e.g 37
DATE=`date +%V`