date problem

hi everyone

i have another date problem

i need to find out the last week number and in that last week i need to find out at what day monday comes.

please help

The solution depend on your operating system.

# uname -v
FreeBSD 7.3-RELEASE-p3 #0: Tue Nov  2 22:42:55 CET 2010


# date -v -1w -v $((($(date +%u) - 1)* -1))d
Mon Mar  7 05:38:32 EST 2011

# date -v -1w -v $((($(date +%u) - 1)* -1))d +%d
07

hi

above command is giving me error as

My operating system is sun solaris can we don this command on this

 
-bash-3.00$ date -v -1w -v $((($(date +%u) - 1)* -1))d
date: illegal option -- v
date: illegal option -- 1
date: illegal option -- w
date: illegal option -- v
date: illegal option -- 1
date: illegal option -- d
usage:  date [-u] mmddHHMM[[cc]yy][.SS]
        date [-u] [+format]
        date -a [-]sss[.fff]
-bash-3.00$ date -v -1w -v $((($(date +%u) - 1)* -1))d +%d
date: illegal option -- v
date: illegal option -- 1
date: illegal option -- w
date: illegal option -- v
date: illegal option -- 1
date: illegal option -- d
usage:  date [-u] mmddHHMM[[cc]yy][.SS]
        date [-u] [+format]
        date -a [-]sss[.fff]
-bash-3.00$

 

My solution work for FreeBSD date only. Sorry but you didn't state you OS from head-start.

okkk can u tell me solution for my operating system

it's imp to me

or

can you tell me the solution if i want to find the last monday of the current date in unix

Take a look at second answer on this thread: date -d compatibility on Solaris - The UNIX and Linux Forums